mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-05 18:26:45 -05:00
23 lines
857 B
TypeScript
23 lines
857 B
TypeScript
// db/queries.ts
|
|
import { Account } from '../schema/Account'
|
|
import { db } from '../index';
|
|
|
|
// Fetch all account
|
|
export async function getAllAccounts() {
|
|
return await db.select().from(Account);
|
|
}
|
|
|
|
// Add a new account
|
|
export async function addAcount(first_name: string, last_name : string, username : string, password_hash: string ) {
|
|
return await db.insert(Account).values({ first_name, last_name, username, password_hash }).returning();
|
|
}
|
|
|
|
// Update a account
|
|
export async function updateAcount(id: number, first_name: string, last_name : string, username : string, password_hash: string ) {
|
|
return await db.update(Account).set({ first_name, last_name, username, password_hash }).where(Account.id.equals(id));
|
|
}
|
|
|
|
// Delete a account
|
|
export async function deleteAccount(id: number) {
|
|
return await db.delete(Account).where(Account.id.equals(id));
|
|
} |