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

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() {
return instance
}
DAOFactory.prototype.create = function(values, fields) {
return this.build(values).save(fields)
DAOFactory.prototype.create = function(values, fieldsOrOptions) {
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) {
......@@ -568,8 +571,12 @@ module.exports = (function() {
}).run()
}
DAOFactory.prototype.findOrCreate = function (params, defaults) {
var self = this;
DAOFactory.prototype.findOrCreate = function (params, defaults, options) {
var self = this
options = Utils._.extend({
transaction: null
}, options || {})
return new Utils.CustomEventEmitter(function (emitter) {
self.find({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!