How dow I query comments greater than or less than a certain date...
Here is my Schema with Post model and a Comment model:
var mongoose = require(\'mong
Use dot notation to reach inside the embedded array docs. For example, to query for the Post
comments with a created_at
between date1
and date2
:
Post.find({ "comments.created_at": { $gt: date1, $lt: date2 }}, function (err, docs) {
...
});
UPDATE
Thanks for the edit; now I understand that you're trying to to filter the comments of single post by their created_at
date. You can't do that directly with MongoDB queries, but I believe you can do it with the 2.2 aggregation framework if you're at that version. Take a look at the discussion of this feature request on Jira for examples.