mongoose - Mongodb aggregation lookup record limit -


i have function in moongose+mongodb:

   blog.aggregate([{                 "$match": {"user_id": userblog}},                 {                 "$lookup": {                     from: "comments", // collection name in db                     localfield: "_id",                     foreignfield: "blogid",                     as: "comments"                 },                               }]).exec(function(err, docs) {               }); 

this works perfectly, how limit comments , retrive last 10 records? thank's lot. marco.

add limit code

blog.aggregate([{         "$match": {"user_id": userblog}},         {         "$lookup": {             from: "comments", // collection name in db             localfield: "_id",             foreignfield: "blogid",             as: "comments"         }     }]).limit(10).exec(function(err, docs) {      }); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -