How can I get let's say the oldest 5 records from MongoDB using mongoose and after let's say the next 5 records and so on. What I have by now is this
Model.find().sort({time: -1}).limit(5).exec( ...);
But I want after some time to get next 5, how can I do this?
Based on request number update page. eg. first request send page=0, for next page=1 and so on.
var limit = 5;
var page = 0; // 1,2,3,4
return Model.find()
.sort({time: -1})
.limit(limit)
.skip(limit * page)
.exec();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.