mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-05 18:26:45 -05:00
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
"use server";
|
|
import { eq, not , asc} from "drizzle-orm";
|
|
import { revalidatePath } from "next/cache";
|
|
import { db } from "@db/index";
|
|
import { accounts } from "@schemas/schema";
|
|
|
|
export const getData = async () => {
|
|
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(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(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(accounts)
|
|
.set({
|
|
first_name : first_name,
|
|
last_name: last_name,
|
|
username: username,
|
|
email: email,
|
|
password_hash: password_hash
|
|
})
|
|
.where(eq(accounts.userId, id));
|
|
revalidatePath("/");
|
|
}; |