README
waterline-paginator
paginator for waterline models
Installation
$ npm install --save waterline-paginator
Usage
var waterlinePaginator = require('waterline-paginator');
// Model User
var User = {
connection: 'default',
identity: 'user',
schema: true,
tableName: 'area',
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
name: 'string',
type: 'string',
logo: {
model: 'image'
}
}
};
// Model Image
var Image = {
connection: 'default',
identity: 'image',
schema: true,
tableName: 'area',
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
hash: 'string',
url: 'string'
}
};
// Pagination Options
var options = {
model: User,
conditions: {
name: 'eric',
type: 'employee'
},
page: 1,
limit: 10,
sorts: ['id asc', 'name desc'],
populates: [
'logo', 'user'
],
// For Image Fetching
linkKey: {
key: 'logo',
item: 'logo'
},
imageModel: UserLogo
};
// Invocation of pagination
waterlinePaginator.paginate(options, function (error, paginatedList) {
// paginatedList is what you will get
// paginatedList.results is the list of data
});
paginatedList
is what you will get as the paginated result.
License
Apache-2.0 © calidion