fixes, more fixes

This commit is contained in:
2024-12-16 00:25:35 -05:00
parent 76a144111d
commit 813688dee2
14 changed files with 37 additions and 37 deletions

View File

@@ -1,7 +1,7 @@
// db/queries.ts
"use server";
import { eq, not , asc} from "drizzle-orm";
import { Account } from '../../schema/Account'
import { Account } from '@schemas/Account'
import { db } from '../../index';
// Fetch all account

View File

@@ -1,5 +1,5 @@
import { db } from '../../index';
import { psa } from '../../../drizzle/schema';
import { psa } from '@schemas/Psa';
import { eq, lt, gte, ne, and, like } from 'drizzle-orm';
import CATEGORY from '@src/data/parts_cats.json';
@@ -112,6 +112,7 @@ export async function getStocksParts(page = 1) {
.where(eq(psa.fineline, "Stocks"))
.offset(offset);
}
export async function getUpperReciever(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
@@ -133,6 +134,7 @@ export async function getARTriggers(page = 1) {
.where(and(like(psa.fineline, "%Trigger%"), like(psa.category, "Ar Parts")))
.offset(offset);
}
export async function getARParts(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
@@ -143,6 +145,7 @@ export async function getARParts(page = 1) {
.where(and(like(psa.fineline, "%Trigger%"), like(psa.category, "Ar Parts")))
.offset(offset);
}
export async function getMags(page = 1) {
const limit = 40;
const offset = (page - 1) * limit;
@@ -150,6 +153,6 @@ export async function getMags(page = 1) {
return await db.select()
.from(psa)
.limit(limit)
.where(and(like(psa.fineline, "%Magazine%"), like(psa.category, "Ar Parts")))
.where(like(psa.superfineline, "%AR Magazines%"))
.offset(offset);
}

View File

@@ -0,0 +1,18 @@
import { bigint, bigserial, foreignKey, pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { users } from "./User";
export const userActivityLog = pgTable("user_activity_log", {
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
// You can use { mode: "bigint" } if numbers are exceeding js number limitations
userId: bigint("user_id", { mode: "number" }).notNull(),
activity: text().notNull(),
timestamp: timestamp({ mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
}, (table) => {
return {
userActivityLogUserIdFkey: foreignKey({
columns: [table.userId],
foreignColumns: [users.id],
name: "user_activity_log_user_id_fkey"
}).onDelete("cascade"),
}
});