Registry / database / orm-paging

orm-paging

JSON →
library0.0.1jsnpmunverified

Pagination plugin for the ORM2 Node.js library. Current stable version is 0.0.1, with no active development since initial release. Provides `.pages()` and `.page()` chainable methods to compute total pages and retrieve specific pages directly from a model. Configured via `Model.settings.set('pagination.perpage', n)`. Depends on ORM (orm) package. Minimal API surface; no pagination metadata returned, only raw records.

npm install orm-paging
INSTALL
IMPORT
SIG · ORM-PAGING
O
orm-paging
databasejavascriptv0.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

paging
const paging = require('orm-paging');
import paging from 'orm-paging';
Package is CommonJS only; no ESM exports. Use require.
use()
db.use(paging);
orm.use(paging);
paging is a plugin function passed to db.use(), not a method on orm object.
pages/page
Model.settings.set('pagination.perpage', 10); Model.pages(cb); Model.page(3).order('name').run(cb);
Model.perpage = 10; Model.pages().run(cb); Model.page(3).run(cb);
Must use settings.set, not direct assignment. pages() accepts callback, not chainable. page() returns a chainable query.

Connects to MySQL, defines a model, sets pagination to 10 per page, gets total pages and retrieves page 3.

const orm = require('orm'); const paging = require('orm-paging'); orm.connect('mysql://user:pass@localhost/db', (err, db) => { if (err) throw err; db.use(paging); const Person = db.define('person', { name: String, surname: String, age: Number }); Person.settings.set('pagination.perpage', 10); // default 20 // Get total pages Person.pages((err, pages) => { console.log('Total pages:', pages); }); // Get page 3 (records 20-29 ordered by name) Person.page(3).order('name').run((err, people) => { console.log(people); }); });
Debug
Known issues
breakingNo callback error handling on pages() may lead to uncaught exceptions.
fix
Always pass a callback that handles error: .pages((err, pages) => { if (err) throw err; })
affects: >=0.0.0
gotchaPagination methods do not return pagination metadata (total count, current page, etc.), only the records for the requested page.
fix
Use .pages() first to get total count, then calculate metadata manually.
affects: >=0.0.0
gotchapages() expects a callback and does not return a chainable query. page() does not compute total pages.
fix
Use .pages(cb) for total pages; .page(n).run(cb) for data.
affects: >=0.0.0
deprecatedPackage is unmaintained since 2013. It may not work with newer versions of ORM.
fix
Consider alternative pagination methods directly in ORM or use a fork.
affects: >=0.0.0
gotchaPagination per-page must be set via settings.set; direct assignment ignored.
fix
Use Model.settings.set('pagination.perpage', n);
affects: >=0.0.0
Errors
Common errors & fixes
Uncaught TypeError: Model.pages is not a function
Plugin not registered via db.use(paging).
fix
Ensure you call db.use(paging) after connect and before using Model.
Error: Cannot find module 'orm'
Peer dependency orm not installed.
fix
Run: npm install orm
TypeError: Model.page(...).run is not a function
Not calling .run() after .page() chain; .page() returns a query object.
fix
Call .run(callback) at the end of the chain: Model.page(1).run(cb, options?)
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
ormrequiredPeer dependency; plugin adds pagination methods to ORM models
Agent activity
4 hits · last 30 days
node
4
Resources
orm-paging — npm install orm-paging · libregistry