added brands

This commit is contained in:
2024-11-21 15:24:37 -05:00
parent 7b38c8a082
commit ef439d8f1c
7 changed files with 223 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
"use server";
import { eq, not } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { db } from "../db";
import { brand } from "../db/schema/Brand";
export const getData = async () => {
const data = await db.select().from(brand);
return data;
};
export const addBrand = async ( name: string) => {
await db.insert(brand).values({
name: name,
});
};
export const deleteBrand = async (id: number) => {
await db.delete(brand).where(eq(brand.id, id));
revalidatePath("/");
};
export const editBrand = async (id: number, name: string) => {
await db
.update(brand)
.set({
name: name,
})
.where(eq(brand.id, id));
revalidatePath("/");
};