mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 10:46:44 -05:00
getting rid of crap, fixing errors
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
// db/queries.ts
|
||||
"use server";
|
||||
import { eq, not , asc} from "drizzle-orm";
|
||||
import { Account } from '@schemas/Account'
|
||||
import { accounts } from '@schemas/schema'
|
||||
import { db } from '../../index';
|
||||
|
||||
// Fetch all account
|
||||
export async function getAllAccounts() {
|
||||
return await db.select().from(Account);
|
||||
return await db.select().from(accounts);
|
||||
}
|
||||
|
||||
// Add a new account
|
||||
export async function addAcount(first_name: string, last_name : string, username : string, password_hash: string ) {
|
||||
return await db.insert(Account).values({ first_name, last_name, username, password_hash }).returning();
|
||||
return await db.insert(accounts).values({ first_name, last_name, username, password_hash }).returning();
|
||||
}
|
||||
|
||||
// Update a account
|
||||
export async function updateAcount(id: number, first_name: string, last_name : string, username : string, password_hash: string ) {
|
||||
return await db.update(Account).set({ first_name, last_name, username, password_hash }).where(eq(Account.id, id));
|
||||
return await db.update(accounts).set({ first_name, last_name, username, password_hash }).where(eq(accounts.id, id));
|
||||
}
|
||||
|
||||
// Delete a account
|
||||
export async function deleteAccount(id: number) {
|
||||
return await db.delete(Account).where(eq(Account.id, id));
|
||||
return await db.delete(accounts).where(eq(accounts.id, id));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { db } from '../../index';
|
||||
import { db } from '@db/index';
|
||||
import { psa } from '@schemas/schema';
|
||||
import { eq, lt, gte, ne, and, like } from 'drizzle-orm';
|
||||
import CATEGORY from '@src/data/parts_cats.json';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"use server";
|
||||
import { eq, not , asc} from "drizzle-orm";
|
||||
import { products } from '@schemas/schema';
|
||||
import { db } from '../../index';
|
||||
import { db } from '@db/index';
|
||||
|
||||
// Fetch all products
|
||||
export async function getAllProducts() {
|
||||
@@ -15,8 +15,8 @@ export async function addProduct() {
|
||||
}
|
||||
|
||||
// Update a Product
|
||||
export async function updateProduct( ) {
|
||||
return await db.update(products).set({ }).where(eq(Product.id, id));
|
||||
export async function updateProduct( id:number) {
|
||||
return await db.update(products).set({ }).where(eq(products.id, id));
|
||||
}
|
||||
|
||||
// Delete a product
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
import { eq, not , asc} from "drizzle-orm";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { db } from "@db/index";
|
||||
import { State } from "@db/schema/States";
|
||||
import { states } from "@schemas/schema";
|
||||
|
||||
export const getData = async () => {
|
||||
const data = await db.select().from(Account).orderBy(asc(Account.last_name));
|
||||
const data = await db.select().from(states).orderBy(asc(states.abbreviation));
|
||||
return data;
|
||||
};
|
||||
Reference in New Issue
Block a user