Socket
Book a DemoInstallSign in
Socket

mongoose-smartpager

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-smartpager

Paginate mongoose queries using SIZE+1 to determine if there is a next page.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

With mongo-paginate, you can paginate mongoose queries using SIZE+1 to determine if there is a next page.

Installation

$ npm install mongo-paginate --save

Supported options

  paginate([page_number], [page_size], [get_total_of_items])
  • page_number: Number of page to retreive
  • page_size: Number of items per page
  • get_total_of_items: When true, this option makes a count and returns in result the total of items in the collection.

Examples

get_total_of_items = false


 require('mongoose-smartpager');

 this.mongo.model('people').find({})
            .paginate(page, 10, false)
            .then(result => {
                callback(null, result);
            })

Result:

{ 
  "items_per_page": 10,
  "has_next": true,
  "current_page": 1,
  "docs": [ { ... }, { ... } ]
}

get_total_of_items = false


 require('mongoose-smartpager');

 this.mongo.model('people').find({})
            .paginate(page, 10, true)
            .then(result => {
                callback(null, result);
            })

Result:

{ 
  "items_per_page": 10,
  "has_next": true,
  "total_pages": 2,
  "total_items": 15,
  "current_page": 1,
  "docs": [ { ... }, { ... } ]
}

Keywords

pagination

FAQs

Package last updated on 05 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts