summaryrefslogtreecommitdiff
path: root/lib/vendor-document-list/repository.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-07-29 11:48:59 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-07-29 11:48:59 +0000
commit10f90dc68dec42e9a64e081cc0dce6a484447290 (patch)
tree5bc8bb30e03b09a602e7d414d943d0e7f24b1a0f /lib/vendor-document-list/repository.ts
parent792fb0c21136eededecf52b5b4aa1a252bdc4bfb (diff)
(대표님, 박서영, 최겸) document-list-only, gtc, vendorDocu, docu-list-rule
Diffstat (limited to 'lib/vendor-document-list/repository.ts')
-rw-r--r--lib/vendor-document-list/repository.ts36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/vendor-document-list/repository.ts b/lib/vendor-document-list/repository.ts
index 43adf7ca..4eab3853 100644
--- a/lib/vendor-document-list/repository.ts
+++ b/lib/vendor-document-list/repository.ts
@@ -1,5 +1,5 @@
import db from "@/db/db";
-import { documentStagesView } from "@/db/schema/vendorDocu";
+import { documentStagesOnlyView, documentStagesView } from "@/db/schema/vendorDocu";
import {
eq,
inArray,
@@ -42,3 +42,37 @@ export async function countVendorDocuments(
const res = await tx.select({ count: count() }).from(documentStagesView).where(where);
return res[0]?.count ?? 0;
}
+
+
+
+export async function selectDocumentStagesOnly(
+ 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(documentStagesOnlyView)
+ .where(where)
+ .orderBy(...(orderBy ?? []))
+ .offset(offset)
+ .limit(limit);
+}
+
+/** 총 개수 count */
+export async function countDocumentStagesOnly(
+ tx: PgTransaction<any, any, any>,
+ where?: any
+) {
+ const res = await tx.select({ count: count() }).from(documentStagesOnlyView).where(where);
+ return res[0]?.count ?? 0;
+}
+
+
+