Code Monkey home page Code Monkey logo

node-orm-paging's Introduction

ORM Pagination Helper Plugin

This plugin adds a pagination helper function for ORM.

Dependencies

Of course you need orm to use it. Other than that, no more dependencies.

Install

npm install orm-paging

DBMS Support

Any driver supported by ORM is supported by this plugin.

Usage

Model.pages(cb)   // total pages
Model.page(page)  // get page

Example

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)
		});
	});
});

node-orm-paging's People

Contributors

dresende avatar

Stargazers

Giel avatar Jienan Duan avatar Xavier Carpentier avatar  avatar Andrey avatar Bobby Johnson avatar Renato Gama avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

jnduan

node-orm-paging's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.