Comparing version
@@ -132,3 +132,3 @@ /*jshint camelcase:false */ | ||
*/ | ||
CrudCmd.prototype._readList = function(req, res){ | ||
CrudCmd.prototype._readList = function(req, res) { | ||
// render the template and store in response locals. | ||
@@ -157,3 +157,4 @@ res.locals[CrudCmd.VIEW_OUTPUT_KEY] = this.compiled.list(res.locals); | ||
var self = this; | ||
return this.entity.readOne(query).then(function(doc){ | ||
return this.entity.readOne(query).then(function(doc) { | ||
// assign the item to the tpl vars. | ||
@@ -166,3 +167,2 @@ res.locals.item = doc; | ||
res.locals[CrudCmd.VIEW_OUTPUT_KEY] = self.compiled.view(res.locals); | ||
if (!self.opts.layoutView) { | ||
@@ -197,2 +197,3 @@ res.send(res.locals[CrudCmd.VIEW_OUTPUT_KEY]); | ||
return this.entity.update(req.body.id, this.process(req.body)) | ||
.then(this.entity.readOne.bind(this.entity, req.body.id)) | ||
.then(this._handleUpdate.bind(this, req, res)) | ||
@@ -199,0 +200,0 @@ .catch(this.handleError.bind(this, req, res, req.header('Referer'))); |
@@ -10,3 +10,2 @@ /** | ||
var sanitize = require('validator').sanitize; | ||
var pagination = require('pagination'); | ||
@@ -51,10 +50,11 @@ | ||
res, next) { | ||
var page = sanitize(req.query.page).toInt() || 1; | ||
var limit = sanitize(req.query.show).toInt() || opts.limit; | ||
var page = parseInt(req.query.page, 10) || 1; | ||
var limit = parseInt(req.query.show, 10) || opts.limit; | ||
var skip = (page - 1) * limit; | ||
return this.getLimitAndCount(opts.query, skip, limit) | ||
.then(function(results){ | ||
.then(function(results) { | ||
var items = results[0]; | ||
var count = results[1]; | ||
if (!items || !__.isArray(items) || 0 === items.length) { | ||
@@ -89,3 +89,3 @@ // TODO handle this better | ||
Pagination.prototype.getLimitAndCount = function(query, skip, limit) { | ||
return Promise.settle([ | ||
return Promise.all([ | ||
this.entity.readLimit(query, skip, limit), | ||
@@ -92,0 +92,0 @@ this.entity.count(), |
{ | ||
"name": "crude", | ||
"description": "Seamless CRUD control operations for node.", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"homepage": "https://github.com/talksession/node-crude", | ||
@@ -34,17 +34,17 @@ "author": { | ||
"dependencies": { | ||
"pagination": "~0.3.3", | ||
"validator": "~1.2.1", | ||
"lodash": "~1.3.1", | ||
"jade": "~0.31.2", | ||
"mime": "~1.2.9", | ||
"node-entity": "~0.2.1", | ||
"middlewarify": "~0.3.2", | ||
"pagination": "~0.3.8", | ||
"validator": "~3.2.1", | ||
"lodash": "~2.4.1", | ||
"jade": "~1.1.5", | ||
"mime": "~1.2.11", | ||
"node-entity": "~0.2.2", | ||
"middlewarify": "~0.3.4", | ||
"cip": "~0.2.1", | ||
"bluebird": "~1.0.4" | ||
"bluebird": "~1.0.5" | ||
}, | ||
"devDependencies": { | ||
"sinon": "~1.7.3", | ||
"mocha": "~1.11.0", | ||
"chai": "~1.7.1", | ||
"grunt": "~0.4.1", | ||
"sinon": "~1.8.2", | ||
"mocha": "~1.17.1", | ||
"chai": "~1.9.0", | ||
"grunt": "~0.4.2", | ||
"grunt-release": "~0.7.0" | ||
@@ -51,0 +51,0 @@ }, |
@@ -32,2 +32,6 @@ # node-crude | ||
## Release History | ||
- **v0.2.3**, *19 Feb 2014* | ||
- Upgrade all dependencies to latest. | ||
- Perform a READ after an UPDATE. | ||
- Bug fixes. | ||
- **v0.2.2**, *18 Feb 2014* | ||
@@ -34,0 +38,0 @@ - Bug fixes. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
30090
0.67%66
6.45%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated