I want to query mongoDB with document structure like this:
var ExampleSchema = mongoose.Schema({
createdAt: { type: Date, default: Date.now },
validUntil: Date,
name: String
});
and need it to return only valid documents, i.e. where validUntil is greater than current time. This doesn't work, mongoose returns all documents:
var d = new Date();
var n = d.toISOString();
Example.find({ '$where': 'validUntil'>n })