1.0.0 • Published 8 years ago

pagina v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

pagina

NPM version build status Codecov

Paginate any collection and add links to the next/prev page.

Features

  • converts a response body containing a JSON array into a pagination object
  • no need to modify existing route handlers
  • works independently of your datastore, convenient for small datasets loaded into memory

Install

npm install pagina --save

Examples

const express = require('express');
const app = express();
const paginate = require('pagina');

// without pagination

app.get('/items', (req, res, next) => {
  Item
    .find({ owner: req.user })
    .then(items => res.status(200).json(items))
}); 
  
// [1, 2, 3, 4]

// with pagination

// query params override options
const options = { start: 0, limit: 3 }; 

app.get('/items', paginate(options), (req, res, next) => {
  Item
    .find({ owner: req.user })
    .then(items => res.status(200).json(items))
}); 
  
// { 
//   "items": [1, 2, 3], 
//   "prev": null,
//   "next": "http://localhost/items?start=3&limit=3"
// }

License

MIT

TODO

http://tools.ietf.org/html/rfc5988#page-6

1.0.0

8 years ago

0.7.4

8 years ago

0.7.3

8 years ago

0.7.2

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago