mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 10:46:44 -05:00
more database design
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
// db/queries.ts
|
||||
import { accounts } from '../schema/Account'
|
||||
import { Account } from '../schema/Account'
|
||||
import { db } from '../index';
|
||||
|
||||
// Fetch all accounts
|
||||
// Fetch all account
|
||||
export async function getAllAccounts() {
|
||||
return await db.select().from(accounts);
|
||||
return await db.select().from(Account);
|
||||
}
|
||||
|
||||
// Add a new accounts
|
||||
export async function addAcounts(name: string) {
|
||||
return await db.insertInto(accounts).values({ name }).returning();
|
||||
// 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 accounts
|
||||
export async function updateAcounts(id: number, name: string) {
|
||||
return await db.update(accounts).set({ name }).where(accounts.id.equals(id));
|
||||
// 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 accounts
|
||||
// Delete a account
|
||||
export async function deleteAccount(id: number) {
|
||||
return await db.deleteFrom(accounts).where(accounts.id.equals(id));
|
||||
return await db.delete(Account).where(Account.id.equals(id));
|
||||
}
|
||||
Reference in New Issue
Block a user