Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #44 from myanzik/manage-user-roles
Browse files Browse the repository at this point in the history
Closes #43 Search user by name
  • Loading branch information
myanzik authored Jul 21, 2021
2 parents 927740f + 30eee50 commit 77b6ae8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions modules/user/user.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ const controllers = {
const query = [];
const $match = {};
if (filter) query.push({ $match: filter });
// if (name) query.push({ $match: { 'name.first': { $regex: new RegExp(`${name}`), $options: 'i' } } });
// console.log(name);
if (name) {
query.push({

$match: {
'name.first': { $regex: new RegExp(`${name}`), $options: 'i' },
},
});
// query.push({ $match: { 'name.last': { $regex: new RegExp(`${name}`), $options: 'i' } } });
}
// if (name) {
// $match.name.first = { $regex: new RegExp(`${name}`), $options: 'i' };
// }
Expand All @@ -91,7 +98,7 @@ const controllers = {
limit,
sort,
model: User.model,
query: [],
query,
});
}

Expand Down
2 changes: 1 addition & 1 deletion modules/user/user.validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
list: {

query: Joi.object({
// name: Joi.string(),
name: Joi.string(),
start: Joi.number(),
limit: Joi.number(),
}),
Expand Down

0 comments on commit 77b6ae8

Please sign in to comment.