Reputation: 351
The field "planned_depart_date" uses an html date input is used to select a date. That is saved as an ISO Date but does not have the ISODate() wrapper around it when saved to MongoDB. As a result, my queries on "planned_depart_date" return nothing. However, when I query the same thing but on "created_at" (which does have the ISODate() wrapper), it works.
<input type="date" ng-model='trip.planned_depart_date'>
So what's going on? Is there a way to force HTML5 to have the ISODate() wrapper? If not, how can I query my db so that I can get those dates?
I want to query for trips with a planned_depart_date equal to or later than today.
Upvotes: 0
Views: 310
Reputation: 296
ISODate() constructor returns a Date object using the ISODate() wrapper.Convert the coulmn to date.Then you can query as
db.trips.find({"planned_depart_date":{$gte:ISODate("2016-01-15T20:57:31.745Z")}})
Upvotes: 0
Reputation: 351
Alas, I discovered my silly mistake. Notice in the screenshot that all the planned_depart_date
are all strings... My Mongoose model was accepting planned_depart_date
as a string and not a date.
Upvotes: 0