Have ideas to improve npm?Join in the discussion! »

    paginate-for-mongoose

    1.0.1 • Public • Published

    Paginate for mongoose

    Mongoose paginate.

    NPM

    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

    Install

    npm i paginate-for-mongoose

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar