summaryrefslogtreecommitdiff
path: root/lib/general-check-list/repository.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-06-19 09:44:28 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-06-19 09:44:28 +0000
commit95bbe9c583ff841220da1267630e7b2025fc36dc (patch)
tree5e3d5bb3302530bbaa7f7abbe8c9cf8193ccbd4c /lib/general-check-list/repository.ts
parent0eb030580b5cbe5f03d570c3c9d8c519bac3b783 (diff)
(대표님) 20250619 1844 KST 작업사항
Diffstat (limited to 'lib/general-check-list/repository.ts')
-rw-r--r--lib/general-check-list/repository.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/general-check-list/repository.ts b/lib/general-check-list/repository.ts
new file mode 100644
index 00000000..100975ab
--- /dev/null
+++ b/lib/general-check-list/repository.ts
@@ -0,0 +1,49 @@
+import { generalEvaluations } from "@/db/schema";
+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 selectGeneralCheckLists(
+ tx: PgTransaction<any, any, any>,
+ params: {
+ where?: any;
+ orderBy?: (ReturnType<typeof asc> | ReturnType<typeof desc>)[];
+ offset?: number;
+ limit?: number;
+ }
+) {
+
+ const { where, orderBy, offset = 0, limit = 10 } = params;
+
+ return await tx
+ .select()
+ .from(generalEvaluations)
+ .where(where)
+ .orderBy(...(orderBy ?? [asc(generalEvaluations.createdAt)]))
+ .offset(offset ?? 0)
+ .limit(limit ?? 10);
+}
+
+export async function countGeneralCheckList(
+ tx: PgTransaction<any, any, any>,
+ where?: any
+) {
+ const result = await tx
+ .select({ count: count() })
+ .from(generalEvaluations)
+ .where(where);
+
+ return result[0]?.count ?? 0;
+} \ No newline at end of file