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

Commit 4f6a4426 by Sascha Depold

validate parameters of DaoFactory.create

1 parent 0e0cbf19
Showing with 11 additions and 4 deletions
...@@ -531,8 +531,11 @@ module.exports = (function() { ...@@ -531,8 +531,11 @@ module.exports = (function() {
return instance return instance
} }
DAOFactory.prototype.create = function(values, fields) { DAOFactory.prototype.create = function(values, fieldsOrOptions) {
return this.build(values).save(fields) Utils.validateParameter(values, Object, { optional: true })
Utils.validateParameter(fieldsOrOptions, Object, { deprecated: Array, optional: true })
return this.build(values).save(fieldsOrOptions)
} }
DAOFactory.prototype.findOrInitialize = DAOFactory.prototype.findOrBuild = function (params, defaults) { DAOFactory.prototype.findOrInitialize = DAOFactory.prototype.findOrBuild = function (params, defaults) {
...@@ -568,8 +571,12 @@ module.exports = (function() { ...@@ -568,8 +571,12 @@ module.exports = (function() {
}).run() }).run()
} }
DAOFactory.prototype.findOrCreate = function (params, defaults) { DAOFactory.prototype.findOrCreate = function (params, defaults, options) {
var self = this; var self = this
options = Utils._.extend({
transaction: null
}, options || {})
return new Utils.CustomEventEmitter(function (emitter) { return new Utils.CustomEventEmitter(function (emitter) {
self.find({ self.find({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!