Skip to content

Commit

Permalink
user endpoint query value error fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmet AYDIN committed Jun 11, 2020
1 parent 1f8c0fd commit 4fa0f10
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libs/services/resource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ export class ResourceService<T extends any, C extends any, U extends any> {
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,
Expand Down

0 comments on commit 4fa0f10

Please sign in to comment.