npm install mongoose-paginate-pages
var paginate = require('mongoose-paginate-pages');
Schema.plugin(paginate);
Model.paginate(query, options, function(err, results, total, pages) {
......
});
-
Options
page
limit
lean
sortBy
columns
populate
-
Callback(err, results, total, pages)
results
the results of querytotal
equals Model.count(query)pages
equals Math.ceil(total / limit)
npm install && npm test
edwardhotchkiss/mongoose-paginate
MIT