mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 10:46:44 -05:00
lots of work
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { db } from '../../index';
|
||||
import { psa } from '../../../drizzle/schema';
|
||||
import { eq, lt, gte, ne } from 'drizzle-orm';
|
||||
import { eq, lt, gte, ne, and, like } from 'drizzle-orm';
|
||||
import CATEGORY from '@src/data/parts_cats.json';
|
||||
|
||||
export async function getPSA(page = 1) {
|
||||
@@ -43,6 +43,93 @@ export async function getProductType(productType : any, page = 1) {
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(eq(psa.fineline, productType.name))
|
||||
.where(eq(psa.fineline, (typeof(productType) !== 'string' ? productType.name : productType)))
|
||||
.offset(offset);
|
||||
}
|
||||
|
||||
export async function getGrips(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(eq(psa.fineline, "Grips"))
|
||||
.offset(offset);
|
||||
}
|
||||
|
||||
export async function getARHandGuards(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(and(eq(psa.fineline, "Handguards & Rail Systems"), eq(psa.category, 'Ar Parts')))
|
||||
.offset(offset);
|
||||
}
|
||||
|
||||
export async function getAKHandGuards(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(and(eq(psa.fineline, "Handguards & Rail Systems"), eq(psa.category, 'Ak Parts')))
|
||||
.offset(offset);
|
||||
}
|
||||
|
||||
export async function getMuzzleDevices(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(eq(psa.fineline, "Muzzle Brakes"))
|
||||
.offset(offset);
|
||||
}
|
||||
|
||||
export async function getStocks(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(eq(psa.fineline, "Stocks"))
|
||||
.offset(offset);
|
||||
}
|
||||
|
||||
export async function getStocksParts(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(eq(psa.fineline, "Stocks"))
|
||||
.offset(offset);
|
||||
}
|
||||
export async function getUpperReciever(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(like(psa.fineline, "%Upper Receivers"))
|
||||
.offset(offset);
|
||||
}
|
||||
|
||||
export async function getARTriggers(page = 1) {
|
||||
const limit = 40;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return await db.select()
|
||||
.from(psa)
|
||||
.limit(limit)
|
||||
.where(and(like(psa.fineline, "%Trigger%"), like(psa.category, "Ar Parts")))
|
||||
.offset(offset);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export async function getAllProducts() {
|
||||
|
||||
// Add a new product
|
||||
export async function addProduct() {
|
||||
return await db.insert(Product).values({}).returning();
|
||||
return await db.insert(Product).values({ }).returning();
|
||||
}
|
||||
|
||||
// Update a Product
|
||||
|
||||
Reference in New Issue
Block a user