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,30 +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 { brands } from "@schemas/schema";
export const getData = async () => {
const data = await db.select().from(brand).orderBy(asc(brand.name));
const data = await db.select().from(brands).orderBy(asc(brands.name));
return data;
};
export const addBrand = async ( name: string) => {
await db.insert(brand).values({
await db.insert(brands).values({
name: name,
});
};
export const deleteBrand = async (id: number) => {
"use server";
await db.delete(brand).where(eq(brand.id, id));
await db.delete(brands).where(eq(brands.id, id));
revalidatePath("/Brands");
};
export const editBrand = async (id: number, name: string) => {
await db
.update(brand)
.update(brands)
.set({
name: name,
})
.where(eq(brand.id, id));
.where(eq(brands.id, id));
revalidatePath("/");
};