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

Commit 1bdf42dd by Jan Aagaard Meier

cleaning up

1 parent defcb043
Showing with 5 additions and 16 deletions
...@@ -23,18 +23,11 @@ module.exports = (function() { ...@@ -23,18 +23,11 @@ module.exports = (function() {
// the id is in the target table // the id is in the target table
HasOne.prototype.injectAttributes = function() { HasOne.prototype.injectAttributes = function() {
var newAttributes = {}, var newAttributes = {}
self = this
this.identifier = this.options.foreignKey || Utils._.underscoredIf(Utils.singularize(this.source.tableName) + "Id", this.options.underscored) this.identifier = this.options.foreignKey || Utils._.underscoredIf(Utils.singularize(this.source.tableName) + "Id", this.options.underscored)
if(Utils.isHash(this.identifier)) { newAttributes[this.identifier] = { type: DataTypes.INTEGER }
Utils._.each(this.identifier, function(elem, key) {
newAttributes[key] = self.identifier[key].type || DataTypes.INTEGER
})
} else {
newAttributes[this.identifier] = { type: DataTypes.INTEGER }
}
Utils._.extend(this.target.rawAttributes, newAttributes) Utils._.extend(this.target.rawAttributes, newAttributes)
...@@ -43,13 +36,9 @@ module.exports = (function() { ...@@ -43,13 +36,9 @@ module.exports = (function() {
HasOne.prototype.injectGetter = function(obj) { HasOne.prototype.injectGetter = function(obj) {
var self = this var self = this
, where = {}
obj[this.accessors.get] = function() {
var id = obj.id where[self.identifier] = id
, where = Utils.setAttributes({}, self.identifier, obj)
return self.target.find({where: where})
}
return this return this
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!