summaryrefslogtreecommitdiff
path: root/lib/equip-class/repository.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/equip-class/repository.ts')
-rw-r--r--lib/equip-class/repository.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/equip-class/repository.ts b/lib/equip-class/repository.ts
new file mode 100644
index 00000000..ddf98dd2
--- /dev/null
+++ b/lib/equip-class/repository.ts
@@ -0,0 +1,45 @@
+import db from "@/db/db";
+import { Item, items } from "@/db/schema/items";
+import { tagClasses } from "@/db/schema/vendorData";
+import {
+ eq,
+ inArray,
+ not,
+ asc,
+ desc,
+ and,
+ ilike,
+ gte,
+ lte,
+ count,
+ gt,
+} from "drizzle-orm";
+import { PgTransaction } from "drizzle-orm/pg-core";
+
+export async function selectTagClassLists(
+ tx: PgTransaction<any, any, any>,
+ params: {
+ where?: any; // drizzle-orm의 조건식 (and, eq...) 등
+ orderBy?: (ReturnType<typeof asc> | ReturnType<typeof desc>)[];
+ offset?: number;
+ limit?: number;
+ }
+ ) {
+ const { where, orderBy, offset = 0, limit = 10 } = params;
+
+ return tx
+ .select()
+ .from(tagClasses)
+ .where(where)
+ .orderBy(...(orderBy ?? []))
+ .offset(offset)
+ .limit(limit);
+ }
+ /** 총 개수 count */
+ export async function countTagClassLists(
+ tx: PgTransaction<any, any, any>,
+ where?: any
+ ) {
+ const res = await tx.select({ count: count() }).from(tagClasses).where(where);
+ return res[0]?.count ?? 0;
+ } \ No newline at end of file