1.0.0 • Published 9 years ago
pagina v1.0.0
pagina
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 --saveExamples
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
1.0.0
9 years ago
0.7.4
10 years ago
0.7.3
10 years ago
0.7.2
10 years ago
0.7.1
10 years ago
0.7.0
10 years ago
0.6.0
10 years ago
0.5.2
10 years ago
0.5.1
10 years ago
0.5.0
10 years ago
0.4.2
10 years ago
0.4.1
10 years ago
0.4.0
10 years ago
0.3.1
10 years ago
0.3.0
10 years ago
0.2.2
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.0
10 years ago