mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
23 lines
623 B
TypeScript
23 lines
623 B
TypeScript
|
|
// db/queries.ts
|
||
|
|
import { accounts } from '../schema/accounts'
|
||
|
|
import { db } from '../index';
|
||
|
|
|
||
|
|
// Fetch all accounts
|
||
|
|
export async function getAllAccounts() {
|
||
|
|
return await db.select().from(accounts);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Add a new accounts
|
||
|
|
export async function addAcounts(name: string) {
|
||
|
|
return await db.insertInto(User).values({ name }).returning();
|
||
|
|
}
|
||
|
|
|
||
|
|
// Update a user
|
||
|
|
export async function updateUser(id: number, name: string) {
|
||
|
|
return await db.update(User).set({ name }).where(User.id.equals(id));
|
||
|
|
}
|
||
|
|
|
||
|
|
// Delete a user
|
||
|
|
export async function deleteUser(id: number) {
|
||
|
|
return await db.deleteFrom(User).where(User.id.equals(id));
|
||
|
|
}
|