diff options
Diffstat (limited to 'lib/vendor-document-list/repository.ts')
| -rw-r--r-- | lib/vendor-document-list/repository.ts | 36 |
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; +} + + + |
