From b0bd401f258d4725575e123ed1c7a8cafda1a4be Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 24 Oct 2024 17:48:54 +0700 Subject: [PATCH] feat: add util function to include or not include condition --- src/utils/relation.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/relation.ts b/src/utils/relation.ts index b5ac523..fde2c6d 100644 --- a/src/utils/relation.ts +++ b/src/utils/relation.ts @@ -27,3 +27,7 @@ export function whereAddressQuery(query: string) { { subDistrict: { zipCode: { contains: query } } }, ]; } + +export function queryOrNot(query: string, where: T): T | undefined { + return !!query ? where : undefined; +}