I have a function that creates a query object for me based on a number of conditions:
compileSearchCriteria(search){
var conditions = {
published: true
};
conditions["publishedDate"] = {$lte: new Date(search.searchDate)};
<more code here>
return conditions;
},
Dates are stored as ISODates in MongoDB. The resulting query looks like this:
{"published":true,"publishedDate":{"$lte":"2016-03-27T16:23:12.000Z"}}
and returns nothing.
db.trips.find({"published":true,"publishedDate":{"$lt":ISODate("2016-03-27T15:48:41.866Z")}})
returns desired results. Sending the query direct works as well:
DealsCollection.find({published:true, publishedDate:{$lt: new Date(this.props.searchDate)}}).fetch()
How can I create the query object so that I get proper results?
Update It should work and it does work. The problem seems to be with mini-mongo implementation in Meteor. I separated the calls to see where the disconnect is. The server returned data using the original query. But querying resulting documents from the mini-mongo collection produced no results, even though I can see returned documents in it. That is a different issue. Thank you for pointers.