From 4fa0f1060c8cecc5a3b5123e5e0991ca95b92179 Mon Sep 17 00:00:00 2001 From: Ahmet AYDIN Date: Thu, 11 Jun 2020 22:58:58 +0300 Subject: [PATCH] user endpoint query value error fixed --- libs/services/resource.service.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/services/resource.service.ts b/libs/services/resource.service.ts index d36d459..cc67cc9 100644 --- a/libs/services/resource.service.ts +++ b/libs/services/resource.service.ts @@ -49,6 +49,18 @@ export class ResourceService { const searchValue = await { ...this.generalSearchQuery, ...query }; const userRegex = new RegExp(searchValue.queryText, 'i'); + return await this.mongoModel + .find({ + [searchValue.searchBy]: userRegex, + }) + .limit(Math.max(0, searchValue.size)) + .skip(searchValue.size * (searchValue.page - 1)) + .sort([[`${searchValue.sortBy}`, searchValue.sort]]) + .exec(); + } else { + const searchValue = await { ...this.generalSearchQuery }; + const userRegex = new RegExp(searchValue.queryText, 'i'); + return await this.mongoModel .find({ [searchValue.searchBy]: userRegex,