Skip to content

Commit bd3a7c6

Browse files
author
Andrei Alexandru
committed
products filter departments and search
1 parent 9587112 commit bd3a7c6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

nodejs-restful-api/controllers/ProductController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ router.get('/', (req, res) => {
2222
let departments = req.query.departments;
2323

2424
if(departments && departments.length > 0){
25-
condition={ $and: [ condition, {departments: {$in: departments}}]};
25+
condition={$and: [condition, {departments: {$in: departments}}]};
2626
}
2727

2828
if(search) {
29-
condition = { name: { $regex: search, $options: 'i' } }
29+
condition = {$and: [condition, {name: { $regex: search, $options: 'i' }}]};
3030
}
3131

3232
Product.find(condition, (err, products) => {

0 commit comments

Comments
 (0)