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

Commit 2a5a40c4 by Meg Sharkey

emit sql for external logging

1 parent 28866fa0
......@@ -5,7 +5,6 @@ var HasManyDoubleLinked = module.exports = function(definition, instance) {
this.instance = instance
}
//TODO fix self many-to-many
HasManyDoubleLinked.prototype.injectGetter = function() {
var self = this
......
......@@ -16,12 +16,16 @@ Query.prototype.run = function(query) {
this.bindClient()
if(this.options.logging)
console.log('Executing: ' + this.sql)
console.log('Executing: ' + this.sql)
this.client.query(this.sql, function(err, results, fields) {
//allow clients to listen to sql to do their own logging or whatnot
self.emit('sql', self.sql)
err ? self.onFailure(err) : self.onSuccess(self.sql, results, fields)
}).setMaxListeners(100)
return this
}
......@@ -51,10 +55,12 @@ Query.prototype.onSuccess = function(query, results, fields) {
}
this.unbindClient()
this.emit('success', result)
}
Query.prototype.onFailure = function(err) {
this.unbindClient()
this.emit('failure', err, this.callee)
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!