In SO Question/ Answer there are still some parameters for basis of query.
I am looking for simple query like
p.find().limit(10).exec(function(err, qry){
return qry;
}
In SO Question/ Answer there are still some parameters for basis of query.
I am looking for simple query like
p.find().limit(10).exec(function(err, qry){
return qry;
}
var q = models.Post.find().sort('date', -1).limit(10);
q.execFind(function(err, posts) {
// will be of length 10
});
The following worked for me with Mongoose 3.8.16:
var query = ModelName.find({}, null, {limit: 10, sort: {'epoch': -1}});
query.exec(function(err, docs) { ... });
This gives the last 10 entries in the DB sorted by the field epoch
.