Comparing version 0.5.8 to 0.5.9
@@ -97,4 +97,2 @@ /** | ||
expandPaths: false, | ||
// Callback to set the pagination query. | ||
paginateQuery: null, | ||
// entity Read method | ||
@@ -123,4 +121,9 @@ entityCreate: 'create', | ||
ownUserSchemaProperty: null, | ||
// Set to false to not paginate. | ||
pagination: true, | ||
// Callback to set the pagination query. | ||
paginateQuery: null, | ||
// Default item to limit to on pagination. | ||
paginateLimit: 6, | ||
@@ -127,0 +130,0 @@ // Key value pairs matching attributes to labels |
@@ -170,3 +170,3 @@ /** | ||
var skipKeys = ['from', 'to', 'limit', 'page']; | ||
var skipKeys = ['from', 'to', 'show', 'page']; | ||
@@ -173,0 +173,0 @@ keys.forEach(function(key) { |
@@ -28,13 +28,6 @@ /** | ||
* | ||
* @param {Object=} optObj a hash with options. | ||
* @return {Function} The middleware. | ||
*/ | ||
Pagination.prototype.paginate = function(optOpts) { | ||
var defaultOpts = { | ||
limit: 6, | ||
query: null, | ||
}; | ||
var opts = __.extend(optOpts || {}, defaultOpts); | ||
return this._paginateMiddleware.bind(this, opts); | ||
Pagination.prototype.paginate = function() { | ||
return this._paginateMiddleware.bind(this); | ||
}; | ||
@@ -45,3 +38,2 @@ | ||
* | ||
* @param {Object} opt a hash with options. | ||
* @param {Object} req The request Object. | ||
@@ -53,10 +45,10 @@ * @param {Object} res The response Object. | ||
*/ | ||
Pagination.prototype._paginateMiddleware = Promise.method(function(opts, req, | ||
res, next) { | ||
Pagination.prototype._paginateMiddleware = Promise.method(function(req, res, | ||
next) { | ||
var queryShow = parseInt(req.query.show, 10); | ||
var page = parseInt(req.query.page, 10) || 1; | ||
var limit = queryShow || opts.limit; | ||
var limit = queryShow || this.crude.opts.paginateLimit; | ||
var skip = (page - 1) * limit; | ||
var query = opts.query; | ||
var query = this.crude.opts.query; | ||
if (typeof this.crude.opts.paginateQuery === 'function') { | ||
@@ -63,0 +55,0 @@ query = this.crude.opts.paginateQuery(req); |
{ | ||
"name": "crude", | ||
"description": "Seamless CRUD control operations for node.", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"homepage": "https://github.com/thanpolas/crude", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -36,2 +36,4 @@ # node-crude | ||
- **v0.5.9**, *07 Jul 2014* | ||
- Pagination limit is now configurable via `opts.paginateLimit`. | ||
- **v0.5.8**, *07 Jul 2014* | ||
@@ -38,0 +40,0 @@ - if ownUser flag is on then auth is required. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132
60617
1450