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

Commit 1bdf42dd by Jan Aagaard Meier

cleaning up

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