In the last mongoose (3.8.1 at the time of writing) you do two things differently: (1) you need to pass one sort () argument, which should be an array of constraints or just one constraint, and (2) execFind () disappeared and replaced by exec () instead. Therefore, using mongoose 3.8.1 you will do the following:
var q = models.Post.find({published: true}).sort({'date': -1}).limit(20); q.exec(function(err, posts) {
or you can link it just like this:
models.Post .find({published: true}) .sort({'date': -1}) .limit(20) .exec(function(err, posts) {
marni Dec 15 '13 at 14:43 2013-12-15 14:43
source share