I'm using mongoose 4.7.x and mongodb 3.2. I want to search all date without time. E.g update all obj with this date 2016-12-14
.
In my database I have multiple datetime like this :
2016-12-14 00:00:00.000Z
2016-12-14 00:00:00.000Z
2016-12-14 01:00:00.000Z
2016-12-14 01:00:00.000Z
2016-12-14 02:00:00.000Z
2016-12-14 02:00:00.000Z
I tried this :
var query = {date: new Date('2016-12-14')};
var doc = {name: 'TEST'};
var options = {multi: true};
Model.update(query, doc, options, function(err, result){
console.log('All data updated')
});
But this will just update all fields with time 00:00:00 because new Date()
will returns the datetime.
How can I do to search all fields with a certain date without time ? I can change the model if it's necessary.