Mongodb 查询mongoose中最后10条减去最后5条记录

Mongodb 查询mongoose中最后10条减去最后5条记录,mongodb,mongoose,Mongodb,Mongoose,以上将查询最后10条记录。我可以从中删除前5个:- var q = models.Post.find().sort('date', -1).limit(10); q.execFind(function(err, posts) { // previous 6 to 10th records needed. }); 从第6名到第10名获得记录。但有没有直接查询此类集合的方法?像 posts.splice(0, 4); 我想你在找我 var q = models.Post.find().

以上将查询最后10条记录。我可以从中删除前5个:-

var q = models.Post.find().sort('date', -1).limit(10);
q.execFind(function(err, posts) {
    // previous 6 to 10th records needed.
});
从第6名到第10名获得记录。但有没有直接查询此类集合的方法?像

posts.splice(0, 4); 

我想你在找我

var q = models.Post.find().sort('date', -1).limit(5 to 10);
以下查询适用于mongoose——请注意,我的模式可能与您的不同:

models.Post.find().skip(5).limit(5)
> Post.find().skip(5).limit(5).exec(function(err, p) { if (err) { console.log("error"); }; console.log(p); })