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

Commit 47c03431 by Mick Hansen

Merge pull request #2342 from werk85/master

Model.build default parameters are now set when an options object is given
2 parents 2bba5462 1522ec17
Showing with 8 additions and 2 deletions
...@@ -954,7 +954,10 @@ module.exports = (function() { ...@@ -954,7 +954,10 @@ module.exports = (function() {
if (Array.isArray(values)) { if (Array.isArray(values)) {
return this.bulkBuild(values, options); return this.bulkBuild(values, options);
} }
options = options || { isNewRecord: true, isDirty: true }; options = Utils._.extend({
isNewRecord: true,
isDirty: true
}, options || {});
if (options.attributes) { if (options.attributes) {
options.attributes = options.attributes.map(function(attribute) { options.attributes = options.attributes.map(function(attribute) {
...@@ -975,7 +978,10 @@ module.exports = (function() { ...@@ -975,7 +978,10 @@ module.exports = (function() {
Model.prototype.bulkBuild = function(valueSets, options) { Model.prototype.bulkBuild = function(valueSets, options) {
options = options || { isNewRecord: true, isDirty: true }; options = Utils._.extend({
isNewRecord: true,
isDirty: true
}, options || {});
if (!options.includeValidated) { if (!options.includeValidated) {
conformOptions(options); conformOptions(options);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!