2.0.0 • Published 7 years ago

mongoose-exec-paginate-plugin v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

mongoose-exec-paginate-plugin

Mongoose plugin for pagination with offset.

const execPaginate = require('mongoose-exec-paginate-plugin')
const options = {
  limit: 3     // default offset
}
schema.plugin(execPaginate, )

const query = {
  limit: 10,    // override limit only for this query
  offset: 10
}

Item
  .find()
  .select('name')
  .sort('-createdAt')
  .execPaginate(query)
{
  "data": [
    {
      "_id": "585ae60d8fa6a4767f36c223",
      "name": "Item 1"
    }
  ],
  "offset": 20
}