不要怂,就是干,撸起袖子干!

Commit 21fcf6a3 by Daniel Durante

Updating from the Model/DAOFactory should now go through .validate(), you can sk…

…ip this by adding a third argument {validate: false}.
1 parent 65fe70fd
Showing with 13 additions and 0 deletions
......@@ -563,10 +563,23 @@ module.exports = (function() {
* @return {Object} A promise which fires `success`, `error`, `complete` and `sql`.
*/
DAOFactory.prototype.update = function(attrValueHash, where, options) {
options = options || {}
options.validate = options.validate || true
if(this.options.timestamps) {
var attr = this.options.underscored ? 'updated_at' : 'updatedAt'
attrValueHash[attr] = Utils.now()
}
if (options.validate === true) {
var validate = this.build(attrValueHash).validate()
if (Object.keys(validate).length > 0) {
return new Utils.CustomEventEmitter(function(emitter) {
emitter.emit('error', validate)
}).run()
}
}
return this.QueryInterface.bulkUpdate(this.tableName, attrValueHash, where, options)
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!