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

Commit 46200fb2 by Markus Hedlund

Refactored away duplicate code in Instance::get()

1 parent 878841b0
Showing with 1 additions and 13 deletions
...@@ -214,19 +214,7 @@ Instance.prototype.get = function(key, options) { ...@@ -214,19 +214,7 @@ Instance.prototype.get = function(key, options) {
for (_key in this.dataValues) { for (_key in this.dataValues) {
if (!values.hasOwnProperty(_key) && this.dataValues.hasOwnProperty(_key)) { if (!values.hasOwnProperty(_key) && this.dataValues.hasOwnProperty(_key)) {
if (options && options.plain && this.options.include && this.options.includeNames.indexOf(_key) !== -1) { values[_key] = this.get(_key, options);
if (Array.isArray(this.dataValues[_key])) {
values[_key] = this.dataValues[_key].map(function (instance) {
return instance.get({plain: options.plain});
});
} else if (this.dataValues[_key] instanceof Instance) {
values[_key] = this.dataValues[_key].get({plain: options.plain});
} else {
values[_key] = this.dataValues[_key];
}
} else {
values[_key] = this.dataValues[_key];
}
} }
} }
return values; return values;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!