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

Commit 2a5a40c4 by Meg Sharkey

emit sql for external logging

1 parent 28866fa0
...@@ -5,7 +5,6 @@ var HasManyDoubleLinked = module.exports = function(definition, instance) { ...@@ -5,7 +5,6 @@ var HasManyDoubleLinked = module.exports = function(definition, instance) {
this.instance = instance this.instance = instance
} }
//TODO fix self many-to-many
HasManyDoubleLinked.prototype.injectGetter = function() { HasManyDoubleLinked.prototype.injectGetter = function() {
var self = this var self = this
......
...@@ -19,9 +19,13 @@ Query.prototype.run = function(query) { ...@@ -19,9 +19,13 @@ Query.prototype.run = function(query) {
console.log('Executing: ' + this.sql) console.log('Executing: ' + this.sql)
this.client.query(this.sql, function(err, results, fields) { 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) err ? self.onFailure(err) : self.onSuccess(self.sql, results, fields)
}).setMaxListeners(100) }).setMaxListeners(100)
return this return this
} }
...@@ -51,10 +55,12 @@ Query.prototype.onSuccess = function(query, results, fields) { ...@@ -51,10 +55,12 @@ Query.prototype.onSuccess = function(query, results, fields) {
} }
this.unbindClient() this.unbindClient()
this.emit('success', result) this.emit('success', result)
} }
Query.prototype.onFailure = function(err) { Query.prototype.onFailure = function(err) {
this.unbindClient() this.unbindClient()
this.emit('failure', err, this.callee) 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!