changing to SortTable

This commit is contained in:
2024-12-15 23:39:56 -05:00
parent 0638a8cd52
commit 76a144111d
10 changed files with 69 additions and 6 deletions

View File

@@ -142,4 +142,14 @@ export async function getARParts(page = 1) {
.limit(limit)
.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;
return await db.select()
.from(psa)
.limit(limit)
.where(and(like(psa.fineline, "%Magazine%"), like(psa.category, "Ar Parts")))
.offset(offset);
}

27
src/db/schema/User.ts Normal file
View File

@@ -0,0 +1,27 @@
import { pgTable, integer, varchar, text, decimal, uuid, real, bigserial, date, timestamp, boolean, unique, check } from "drizzle-orm/pg-core";
import { sql } from "drizzle-orm";
import { timestamps } from "./helpers/columns.helpers";
export const users = pgTable("users", {
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
username: varchar({ length: 50 }).notNull(),
email: varchar({ length: 255 }).notNull(),
passwordHash: varchar("password_hash", { length: 255 }).notNull(),
firstName: varchar("first_name", { length: 50 }),
lastName: varchar("last_name", { length: 50 }),
profilePicture: varchar("profile_picture", { length: 255 }),
dateOfBirth: date("date_of_birth"),
phoneNumber: varchar("phone_number", { length: 20 }),
createdAt: timestamp("created_at", { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
updatedAt: timestamp("updated_at", { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
isAdmin: boolean("is_admin").default(false),
lastLogin: timestamp("last_login", { mode: 'string' }),
emailVerified: boolean("email_verified").default(false),
buildPrivacySetting: text("build_privacy_setting").default('public'),
}, (table) => {
return {
usersUsernameKey: unique("users_username_key").on(table.username),
usersEmailKey: unique("users_email_key").on(table.email),
usersBuildPrivacySettingCheck: check("users_build_privacy_setting_check", sql`build_privacy_setting = ANY (ARRAY['private'::text, 'public'::text])`),
}
});