more fixes and organizing

This commit is contained in:
2024-11-25 17:09:47 -05:00
parent 0dfd533b71
commit 725b62c31a
6 changed files with 33 additions and 6 deletions

View File

@@ -1,8 +1,8 @@
// db/queries.ts
"use server";
import { eq, not , asc} from "drizzle-orm";
import { Account } from '../schema/Account'
import { db } from '../index';
import { Account } from '../../schema/Account'
import { db } from '../../index';
// Fetch all account
export async function getAllAccounts() {

View File

@@ -0,0 +1,25 @@
// db/queries.ts
"use server";
import { eq, not , asc} from "drizzle-orm";
import { Product } from '../../schema/Product'
import { db } from '../../index';
// Fetch all account
export async function getAllProducts() {
return await db.select().from(Product);
}
// Add a new product
export async function addProduct() {
return await db.insert(Product).values({}).returning();
}
// Update a Product
export async function updateProduct( ) {
return await db.update(Product).set({ }).where(eq(Product.id, id));
}
// Delete a product
export async function deleteProduct(id: number) {
return await db.delete(Product).where(eq(Product.id, id));
}