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

    mongojs-paginate

    1.2.0 • Public • Published

    mongojs-paginate

    Build Status Coverage Status

    Query pagination helper for mongojs.

    Installation

    npm install mongojs-paginate
    

    Usage

    var paginate = require('mongojs-paginate');
    
    // Create a mongojs query
    var query = db.commits
      .find(res.locals.filter)
      .sort({ index : -1 });
    
    // Feed the query into paginate query function. Paging object with page and limit fields is required!
    paginate(query, { limit : 3, page : 1 }, function(err, result) {
      // Result:
      // items: containing items of the desired page
      // itemCount: non paged count of items returned by query
      // page: current page
      // pageCount: Number of pages
      // limit: Number of items returned by page
      // next: index of the next page or undefined if no next page exists
      // hasNext: true if next page exists otherwise false
      // previous: index of the previous page or undefined if no previous page exists
      // hasPrevious: true if previous page exists otherwise false
    });
    

    Install

    npm i mongojs-paginate

    DownloadsWeekly Downloads

    2

    Version

    1.2.0

    License

    ISC

    Last publish

    Collaborators

    • avatar