diff --git a/src/services/RecordService.ts b/src/services/RecordService.ts index cff8dcb..6f71183 100644 --- a/src/services/RecordService.ts +++ b/src/services/RecordService.ts @@ -268,6 +268,10 @@ const getRecordsBySearch = async (userId: string, keyword: string): Promise new RegExp(`.*${pattern}.*`); try { + if (!keyword || keyword.trim().length === 0) { + return { recordsCount: 0, records: [] }; + } + const Regex: RegExp = regex(keyword); const recordList = await Record.find({ $or: [