From 1a2241c40e10193c5ff7008a7b7b36cc1d855d96 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Tue, 25 Mar 2025 15:55:45 +0900 Subject: initial commit --- lib/form-list/repository.ts | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lib/form-list/repository.ts (limited to 'lib/form-list/repository.ts') 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, + params: { + where?: any; // drizzle-orm의 조건식 (and, eq...) 등 + orderBy?: (ReturnType | ReturnType)[]; + 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, + where?: any + ) { + const res = await tx.select({ count: count() }).from(tagTypeClassFormMappings).where(where); + return res[0]?.count ?? 0; + } + \ No newline at end of file -- cgit v1.2.3