Similar to Laravels Eloquent feature.

UPDATE: I’ve made this plugin a package.

npm install --save bookshelf-simplepaginate

Use the simplePaginate plugin to call a fetchAll and return single pages with meta data.

Intended for use with large datasets as pagination with counts can be slow.

Example:

bookshelf.plugin(require('./simplepaginate.plugin'));Model.where({ id: 1 }).simplePaginate({ page: 1 }).then(results => {
// results.data
// results.meta
});

Returns:

"data": [],
"meta": {
"pagination": {
"count": 1,
"per_page": 1,
"current_page": 0,
"links": {
"previous": null,
"next": null
}
}
}

Links are integers, not full links.

Will Bowman

Web Developer Since 1998

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store