mongoose-anchor-pagination
Mongoose.js Document Query Pagination with anchors
Pagination plugin for Mongoose
Requirements
Mongoose >= 4.0
Installation
npm mongoose-anchor-pagination
Usage
Add plugin to a schema:
var mongoose = ;var mongooseAnchorPaginate = ; var schema = /* schema definition */ ;schema;
Model.find([query], [fields], [options], [callback])
Parameters
[options]
{Object}[next_anchor]
{String}[prev_anchor]
{String}[sort=_id]
{Object | String} - Sort order. Documentation[limit=10]
{Number}
Examples
Sort all documents, skip with count <= 3 and return 10 documents
Model;
Or you can do the same with ObjectId:
Model;
With promise:
Model;
With populate:
Model;
Tests
npm installnpm test