deleted separate schema files

This commit is contained in:
2024-12-17 13:44:08 -05:00
parent 363259b34c
commit 12493feb6e
37 changed files with 37 additions and 435 deletions

View File

@@ -2,27 +2,27 @@
import { eq, not , asc} from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { db } from "../db";
import { Account } from "../db/schema/Account";
import { accounts } from "@schemas/schema";
export const getData = async () => {
const data = await db.select().from(Account).orderBy(asc(Account.last_name));
const data = await db.select().from(accounts).orderBy(asc(accounts.last_name));
return data;
};
export const addAccount = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
await db.insert(Account).values({
/* await db.insert(accounts).values({
first_name : first_name, last_name: last_name, username: username, password_hash : password_hash
});
}); */
};
export const deleteAccount = async (id: number) => {
await db.delete(Account).where(eq(Account.id, id));
await db.delete(accounts).where(eq(accounts.userId, id));
revalidatePath("/");
};
export const editAccount = async (id: number, first_name: string, last_name: string, username: string, email : string, password_hash: string) => {
await db
.update(Account)
.update(accounts)
.set({
first_name : first_name,
last_name: last_name,
@@ -30,6 +30,6 @@ export const editAccount = async (id: number, first_name: string, last_name: str
email: email,
password_hash: password_hash
})
.where(eq(Account.id, id));
.where(eq(accounts.userId, id));
revalidatePath("/");
};