Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saintedlama/mongojs-paginate
Query pagination helper for mongojs
https://github.com/saintedlama/mongojs-paginate
Last synced: about 14 hours ago
JSON representation
Query pagination helper for mongojs
- Host: GitHub
- URL: https://github.com/saintedlama/mongojs-paginate
- Owner: saintedlama
- License: isc
- Created: 2015-03-10T11:20:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-15T08:05:30.000Z (over 8 years ago)
- Last Synced: 2024-10-12T12:25:41.074Z (about 1 month ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongojs-paginate
[![Build Status](https://travis-ci.org/saintedlama/mongojs-paginate.svg?branch=master)](https://travis-ci.org/saintedlama/mongojs-paginate)
[![Coverage Status](https://coveralls.io/repos/github/saintedlama/mongojs-paginate/badge.svg?branch=master)](https://coveralls.io/github/saintedlama/mongojs-paginate?branch=master)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
});