accounts table and many other fixes

This commit is contained in:
2025-01-19 23:49:48 -05:00
parent 26ae83faac
commit e0688a1406
22 changed files with 208 additions and 43 deletions

View File

@@ -1,14 +1,15 @@
// db/queries.ts
"use server";
import { eq, not , asc} from "drizzle-orm";
import { accounts } from '@schemas/schema'
import { db } from '../../index';
import { accounts } from '@schemas/schema';
import { vw_accounts } from '@schemas/schema';
import { db } from '@db/index';
// Fetch all account
export async function getAllAccounts() {
return await db.select().from(accounts);
}
//@TODO Accounts don't have these fields, i assume next.js auth code did it this way
// Add a new account
export async function addAcount(first_name: string, last_name : string, username : string, password_hash: string ) {
return await db.insert(accounts).values({ first_name, last_name, username, password_hash }).returning();

View File

@@ -102,6 +102,17 @@ export async function getStocks(page = 1) {
.offset(offset);
}
export async function getOptics(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
return await db.select()
.from(psa)
.limit(limit)
.where(and(like(psa.fineline, "%Optics%")))
.offset(offset);
}
export async function getStocksParts(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;