2024-12-11 06:38:50 -05:00
|
|
|
import { db } from '../../index';
|
|
|
|
|
import { psa } from '../../../drizzle/schema';
|
2024-12-12 00:04:14 -05:00
|
|
|
import { eq, lt, gte, ne } from 'drizzle-orm';
|
2024-12-12 16:23:05 -05:00
|
|
|
import CATEGORY from '@src/data/parts_cats.json';
|
2024-12-11 06:38:50 -05:00
|
|
|
|
|
|
|
|
export async function getPSA(page = 1) {
|
2024-12-12 00:04:14 -05:00
|
|
|
const limit = 20;
|
2024-12-11 06:38:50 -05:00
|
|
|
const offset = (page - 1) * limit;
|
|
|
|
|
|
|
|
|
|
return await db.select()
|
|
|
|
|
.from(psa)
|
|
|
|
|
.limit(limit)
|
2024-12-12 00:04:14 -05:00
|
|
|
.where(eq(psa.fineline, "Lower Build Kits"))
|
2024-12-11 06:38:50 -05:00
|
|
|
.offset(offset);
|
2024-12-12 00:04:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getLowerBuildKits(page = 1) {
|
|
|
|
|
const limit = 20;
|
|
|
|
|
const offset = (page - 1) * limit;
|
|
|
|
|
|
|
|
|
|
return await db.select()
|
|
|
|
|
.from(psa)
|
|
|
|
|
.limit(limit)
|
|
|
|
|
.where(eq(psa.fineline, "Lower Build Kits"))
|
|
|
|
|
.offset(offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getARCompleteLowers(page = 1) {
|
2024-12-12 10:34:50 -05:00
|
|
|
const limit = 40;
|
2024-12-12 00:04:14 -05:00
|
|
|
const offset = (page - 1) * limit;
|
|
|
|
|
|
|
|
|
|
return await db.select()
|
|
|
|
|
.from(psa)
|
|
|
|
|
.limit(limit)
|
|
|
|
|
.where(eq(psa.fineline, "AR Complete Lowers"))
|
|
|
|
|
.offset(offset);
|
|
|
|
|
}
|
2024-12-12 16:23:05 -05:00
|
|
|
|
|
|
|
|
export async function getProductType(productType : any, page = 1) {
|
|
|
|
|
const limit = 40;
|
|
|
|
|
const offset = (page - 1) * limit;
|
|
|
|
|
|
|
|
|
|
return await db.select()
|
|
|
|
|
.from(psa)
|
|
|
|
|
.limit(limit)
|
|
|
|
|
.where(eq(psa.fineline, productType.name))
|
|
|
|
|
.offset(offset);
|
|
|
|
|
}
|