Socket
Socket
Sign inDemoInstall

mongoose-smartpager

Package Overview
Dependencies
225
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

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.


Version published
Maintainers
1
Install size
7.92 MB
Created

Readme

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

FAQs

Last updated on 05 May 2020

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc