https://github.com/dresende/node-orm-paging
NodeJS ORM Pagination Helper
https://github.com/dresende/node-orm-paging
Last synced: 10 months ago
JSON representation
NodeJS ORM Pagination Helper
- Host: GitHub
- URL: https://github.com/dresende/node-orm-paging
- Owner: dresende
- Created: 2013-05-04T09:22:15.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-02-25T08:16:39.000Z (almost 9 years ago)
- Last Synced: 2025-03-18T17:24:47.739Z (10 months ago)
- Language: JavaScript
- Homepage: http://dresende.github.io/node-orm-paging
- Size: 112 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ORM Pagination Helper Plugin [](https://npmjs.org/package/orm-paging)
This plugin adds a pagination helper function for [ORM](http://dresende.github.io/node-orm2).
## Dependencies
Of course you need `orm` to use it. Other than that, no more dependencies.
## Install
```sh
npm install orm-paging
```
## DBMS Support
Any driver supported by ORM is supported by this plugin.
## Usage
```js
Model.pages(cb) // total pages
Model.page(page) // get page
```
## Example
```js
var orm = require("orm");
var paging = require("orm-paging");
orm.connect("mysql://username:password@host/database", function (err, db) {
if (err) throw err;
db.use(paging);
var Person = db.define("person", {
name : String,
surname : String,
age : Number
});
Person.settings.set("pagination.perpage", 10); // default is 20
Person.pages(function (err, pages) {
console.log("Total pages: %d", pages);
Person.page(3).order("name").run(function (err, people) {
// should get you page 3, which means people from index 20 to 29 (ordered by name)
});
});
});
```