https://github.com/lsongdev/mongoose-paginate
mongoose-paginate
https://github.com/lsongdev/mongoose-paginate
Last synced: about 1 year ago
JSON representation
mongoose-paginate
- Host: GitHub
- URL: https://github.com/lsongdev/mongoose-paginate
- Owner: lsongdev
- Created: 2014-06-11T03:31:43.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-11T06:04:45.000Z (almost 12 years ago)
- Last Synced: 2025-03-28T15:32:30.934Z (about 1 year ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Paginate for mongoose
[Mongoose](https://github.com/LearnBoost/mongoose) paginate.
[](https://nodei.co/npm/paginate-for-mongoose/)
## Installation
$ npm install paginate-for-mongoose
## Example
require('paginate-for-mongoose');
var options = {
perPage: 10,
delta : 3,
page : req.query.page
};
var query = MyModel.find({deleted: false}).sort('name', 1);
query.paginate(options, function(err, res) {
console.log(res); // => res = {
// options: options, // paginate options
// results: [Document, ...], // mongoose results
// current: 5, // current page number
// last: 12, // last page number
// prev: 4, // prev number or null
// next: 6, // next number or null
// pages: [ 2, 3, 4, 5, 6, 7, 8 ], // page numbers
// count: 125 // document count
//};
});
## License
The MIT License