summaryrefslogtreecommitdiff
path: root/lib/form-list/repository.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-03-26 00:37:41 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-03-26 00:37:41 +0000
commite0dfb55c5457aec489fc084c4567e791b4c65eb1 (patch)
tree68543a65d88f5afb3a0202925804103daa91bc6f /lib/form-list/repository.ts
3/25 까지의 대표님 작업사항
Diffstat (limited to 'lib/form-list/repository.ts')
-rw-r--r--lib/form-list/repository.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/form-list/repository.ts b/lib/form-list/repository.ts
new file mode 100644
index 00000000..ced320db
--- /dev/null
+++ b/lib/form-list/repository.ts
@@ -0,0 +1,46 @@
+import db from "@/db/db";
+import { Item, items } from "@/db/schema/items";
+import { tagTypeClassFormMappings } 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 selectFormLists(
+ 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(tagTypeClassFormMappings)
+ .where(where)
+ .orderBy(...(orderBy ?? []))
+ .offset(offset)
+ .limit(limit);
+ }
+ /** 총 개수 count */
+ export async function countFormLists(
+ tx: PgTransaction<any, any, any>,
+ where?: any
+ ) {
+ const res = await tx.select({ count: count() }).from(tagTypeClassFormMappings).where(where);
+ return res[0]?.count ?? 0;
+ }
+ \ No newline at end of file