mongojs icon indicating copy to clipboard operation
mongojs copied to clipboard

Query doesn't send me back an empty array.

Open Jcardo97 opened this issue 7 years ago • 2 comments

Hi guys! I need help. I'm trying to make a query, but the array is empty and I can not see the error in my code. The data is getting right to the back end and if I use the same data in a direct query from the mongo shield if I return the data. I appreciate any help you can give me.

I attach my code

router.get('/tasks/:date1/:date2', (req, res, next) => { console.log(req.params.date1); console.log(req.params.date2); db.studentServices.find({ "Fecha" : {$gte: req.params.date1, $lte : req.params.date2}}, (err, studentService) => { if(err) return next(err); console.log(studentService); res.json(studentService); }); });

Jcardo97 avatar Apr 06 '18 20:04 Jcardo97

Could you provide some data as well as the console log output for a certain scenario given date1 and date2

saintedlama avatar Apr 07 '18 05:04 saintedlama

2018-04-10_12-51-25

Yes no problem, use date in epoch format because it is more easy to save the date. https://ufidelitas.ac.cr/assets/en/Josue/2018-04-10_12-51-25.png In that URL we can see output from date1 (date begin) and date2 (date end) and empty array. In another site i make a request from all the information in the collection and send me back all information with date . Attached URL with Image https://ufidelitas.ac.cr/assets/en/Josue/2018-04-10_12-54-29.png 2018-04-10_12-54-29

and whem I use that information to make a consult directly from database it work´s.

Thanks for help.

Jcardo97 avatar Apr 10 '18 19:04 Jcardo97