diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-30 08:28:13 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-30 08:28:13 +0000 |
| commit | 5b6313f16f508882a0ea67716b7dbaa1c6967f04 (patch) | |
| tree | 3d1d8dafea2f31274ace3fbda08333e889e06d1c /lib/admin-users/repository.ts | |
| parent | 3f0fad18483a5c800c79c5e33946d9bb384c10e2 (diff) | |
(대표님) 20250630 16시 - 유저 도메인별 라우터 분리와 보안성검토 대응
Diffstat (limited to 'lib/admin-users/repository.ts')
| -rw-r--r-- | lib/admin-users/repository.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/admin-users/repository.ts b/lib/admin-users/repository.ts index aff2da28..63e98b4e 100644 --- a/lib/admin-users/repository.ts +++ b/lib/admin-users/repository.ts @@ -49,6 +49,30 @@ export async function selectUsersWithCompanyAndRoles( return rows } +export async function selectUsers( + 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 + + // 1) 쿼리 빌더 생성 + const queryBuilder = tx + .select() + .from(users) + .where(where) + .orderBy(...(orderBy ?? [])) + .offset(offset) + .limit(limit) + + const rows = await queryBuilder + return rows +} + /** 총 개수 count */ export async function countUsers( @@ -59,6 +83,14 @@ export async function countUsers( return res[0]?.count ?? 0; } +export async function countUsersSimple( + tx: PgTransaction<any, any, any>, + where?: any +) { + const res = await tx.select({ count: count() }).from(users).where(where); + return res[0]?.count ?? 0; +} + export async function groupByCompany( tx: PgTransaction<any, any, any>, ) { |
