diff --git a/app.js b/app.js index 0057f88..4ed05b3 100644 --- a/app.js +++ b/app.js @@ -542,7 +542,22 @@ app.post('/apiPostDailyReport/:apiKey',function(req,res){ app.get('/filter', utils.ensureAuthenticated, function(req, res) { //console.log(req.query.year.value); - var query={$or:[{$and:[{"workDate": { "$regex": req.query.year, "$options": "i" }},{"title":{ "$regex": req.query.condition, "$options": "i" }}]},{$and:[{"workDate": { "$regex": req.query.year, "$options": "i" }},{"poNumber":{ "$regex": req.query.condition, "$options": "i" }}]}]}; + var query={ + $or:[ + {"megrendelo": { "$regex": req.query.condition, "$options": "i" }}, + {$and: + [ + {"workDate": { "$regex": req.query.year, "$options": "i" }}, + {"title":{ "$regex": req.query.condition, "$options": "i" }} + ] + },{$and: + [ + {"workDate": { "$regex": req.query.year, "$options": "i" }}, + {"poNumber":{ "$regex": req.query.condition, "$options": "i" }} + ] + } + ] + }; Work.find(query,null,{sort: {workNumber: -1}} ,function(err, works){ if (err)