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

Commit cfc66e9e by Sascha Depold

Emit the sql event of the find method as well

1 parent 4ac8c613
Showing with 27 additions and 25 deletions
......@@ -52,7 +52,7 @@ module.exports = (function() {
if (this.options.constraints !== false) {
this.options.onDelete = this.options.onDelete || 'SET NULL'
this.options.onUpdate = this.options.onUpdate || 'CASCADE'
}
}
Helpers.addForeignKeyConstraints(this.target.rawAttributes[this.identifier], this.source, this.target, this.options)
// Sync attributes and setters/getters to DAO prototype
......@@ -87,32 +87,34 @@ module.exports = (function() {
var instance = this
return new Utils.CustomEventEmitter(function(emitter) {
instance[association.accessors.get]().success(function(oldInstance) {
if (oldInstance) {
oldInstance[association.identifier] = null
oldInstance
.save(Utils._.extend({}, options, {
fields: [association.identifier],
allowNull: [association.identifier],
association: true
}))
.success(function() {
if (associatedInstance) {
associatedInstance.set(association.identifier, instance.get(association.sourceIdentifier))
associatedInstance.save(options).proxy(emitter)
} else {
emitter.emit('success', null)
}
})
} else {
if (associatedInstance) {
associatedInstance.set(association.identifier, instance.get(association.sourceIdentifier))
associatedInstance.save(options).proxy(emitter)
instance[association.accessors.get]()
.success(function(oldInstance) {
if (oldInstance) {
oldInstance[association.identifier] = null
oldInstance
.save(Utils._.extend({}, options, {
fields: [association.identifier],
allowNull: [association.identifier],
association: true
}))
.success(function() {
if (associatedInstance) {
associatedInstance.set(association.identifier, instance.get(association.sourceIdentifier))
associatedInstance.save(options).proxy(emitter)
} else {
emitter.emit('success', null)
}
})
} else {
emitter.emit('success', null)
if (associatedInstance) {
associatedInstance.set(association.identifier, instance.get(association.sourceIdentifier))
associatedInstance.save(options).proxy(emitter)
} else {
emitter.emit('success', null)
}
}
}
})
})
.proxy(emitter, { events: ['sql'] })
}).run()
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!