I have a schema in the below format:
var ServiceSchema = new Schema({ createdAt:Date,name:String,ExpiryDate:Date});
I need to query the database comparing the createdAt and expiryDate and get the results.
Say i need to query the values where createdDate>ExpiryDate
.
Any idea as how to write the query using mongoose will be really helpful.
Ionică Bizău
114k95 gold badges311 silver badges489 bronze badges
asked Feb 7, 2013 at 9:27
1 Answer 1
The following code snippet should work.
ServiceSchema.find( {$where: 'this.createdDate > this.ExpiryDate'},
function(err, results) {
///
});
answered Feb 7, 2013 at 9:37
Sign up to request clarification or add additional context in comments.
1 Comment
Amanda G
Thanks will try and let u know :)
lang-js