mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
accounts stuff
This commit is contained in:
@@ -2,26 +2,30 @@
|
||||
import { eq, not , asc} from "drizzle-orm";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { db } from "../db";
|
||||
import { brand } from "../db/schema/Brand";
|
||||
import { Account } from "../db/schema/Account";
|
||||
export const getData = async () => {
|
||||
const data = await db.select().from(brand).orderBy(asc(brand.name));
|
||||
const data = await db.select().from(Account).orderBy(asc(Account.last_name));
|
||||
return data;
|
||||
};
|
||||
export const addBrand = async ( name: string) => {
|
||||
await db.insert(brand).values({
|
||||
name: name,
|
||||
export const addAccount = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
|
||||
await db.insert(Account).values({
|
||||
first_name : first_name, last_name: last_name, username: username, password_hash : password_hash
|
||||
});
|
||||
};
|
||||
export const deleteBrand = async (id: number) => {
|
||||
await db.delete(brand).where(eq(brand.id, id));
|
||||
export const deleteAccount = async (id: number) => {
|
||||
await db.delete(Account).where(eq(Account.id, id));
|
||||
revalidatePath("/");
|
||||
};
|
||||
export const editBrand = async (id: number, name: string) => {
|
||||
export const editAccount = async (id: number, first_name: string, last_name: string, username: string, email : string, password_hash: string) => {
|
||||
await db
|
||||
.update(brand)
|
||||
.update(Account)
|
||||
.set({
|
||||
name: name,
|
||||
first_name : first_name,
|
||||
last_name: last_name,
|
||||
username: username,
|
||||
email: email,
|
||||
password_hash: password_hash
|
||||
})
|
||||
.where(eq(brand.id, id));
|
||||
.where(eq(Account.id, id));
|
||||
revalidatePath("/");
|
||||
};
|
||||
Reference in New Issue
Block a user