Mongoose Paginater
A Mongoose paginatation plugin, forked from Paginate for mongoose by song940.
paginater
means paginator
.
Installation
$ npm install mongoose-paginater
Usage
var mongoose = ;; var options = perPage: 10 delta : 3 page : reqquerypage; var query = MyModel; query;
Pagination Render
There is a pagination template in the render, and you can set options via paginater's settings.
The defaults:
firstText: 'First' prevText: '«' nextText: '»' lastText: 'Last' totalText: 'Page %d of %d' path: '' // path/to query: {} // the page query is `page=n`, you can add other queries `{query1: 'val', q2: 'v2' }` // the pagination href will be like: `path/to?query1=val&q2=v2&page=n` classNameSpace: '' className: wrap: 'pagination' active: 'active' disable: 'disabled'
In the example folder, the render is used like this:
var options = perPage: 10 delta : 3 page : reqquerypage classNameSpace: 'am' query: q1: 'v1' q2: 'v2'; var query = User; query;
The HTML is for Amaze UI Pagination:
Page 1 of 11 « Prev 1 2 3 4 5 6 7 Next » Last
You can also use rendered HTML to other frameworks, just set classes you want.
Run Example
- Clone this project;
- Install packages and run it;
- Visit
localhost:3007
.
git clone https://github.com/Minwe/mongoose-paginater.git
cd mongoose-paginater/example
npm install
npm start
License
The MIT License