Comparing version 0.2.2 to 0.2.3
@@ -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
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
30090
66
+ Addedasync@0.2.10(transitive)
+ Addedcamelcase@1.2.1(transitive)
+ Addedcharacter-parser@1.2.0(transitive)
+ Addedcommander@2.1.0(transitive)
+ Addedconstantinople@1.0.2(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedjade@1.1.5(transitive)
+ Addedmonocle@1.1.51(transitive)
+ Addedsource-map@0.1.34(transitive)
+ Addedtransformers@2.1.0(transitive)
+ Addeduglify-js@2.4.02.4.24(transitive)
+ Addeduglify-to-browserify@1.0.2(transitive)
+ Addedvalidator@3.2.1(transitive)
+ Addedwindow-size@0.1.0(transitive)
+ Addedwith@2.0.0(transitive)
+ Addedwordwrap@0.0.2(transitive)
+ Addedyargs@3.5.4(transitive)
- Removedastw@0.0.0(transitive)
- Removedcharacter-parser@1.0.2(transitive)
- Removedcommander@1.1.1(transitive)
- Removedesprima@1.0.2(transitive)
- Removedjade@0.31.2(transitive)
- Removedkeypress@0.1.0(transitive)
- Removedlexical-scope@0.0.12(transitive)
- Removedlodash@1.3.1(transitive)
- Removedmonocle@0.1.48(transitive)
- Removedtransformers@2.0.1(transitive)
- Removedvalidator@1.2.2(transitive)
- Removedwith@1.0.4(transitive)
Updatedbluebird@~1.0.5
Updatedjade@~1.1.5
Updatedlodash@~2.4.1
Updatedmiddlewarify@~0.3.4
Updatedmime@~1.2.11
Updatednode-entity@~0.2.2
Updatedpagination@~0.3.8
Updatedvalidator@~3.2.1