For example suppose I have the following schema
var Comments = new Schema({
title : String
, body : String
, date : Date
});
var BlogPost = new Schema({
author : ObjectId
, title : String
, body : String
, buf : Buffer
, date : Date
, comments : [Comments]
, meta : {
votes : Number
, favs : Number
}
});
I know how to query BlogPost by comment attributes. How can I do a query such as getting the latest five comments? i.e. reverse sort all comments by ObjectId and then getting the first five results. Would I need to separate into its own Comments collection to do this?