add project
This commit is contained in:
24
apps/api/src/models/wallet.model.ts
Normal file
24
apps/api/src/models/wallet.model.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { db } from '../config/database';
|
||||
import { generateUlid } from '../utils/ulid';
|
||||
|
||||
export interface WalletRow {
|
||||
id: string;
|
||||
user_id: string;
|
||||
chain: string;
|
||||
address: string;
|
||||
derivation_path: string;
|
||||
created_at: Date;
|
||||
}
|
||||
|
||||
export const WalletModel = {
|
||||
async findByUserId(userId: string): Promise<WalletRow[]> {
|
||||
return db('wallets').where({ user_id: userId });
|
||||
},
|
||||
|
||||
async createMany(
|
||||
wallets: { user_id: string; chain: string; address: string; derivation_path: string }[]
|
||||
): Promise<WalletRow[]> {
|
||||
const withIds = wallets.map((w) => ({ id: generateUlid(), ...w }));
|
||||
return db('wallets').insert(withIds).returning('*');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user