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

Commit 059bab9e by Daniel Durante

Fixed up one off connection clients for Sequelize (if client is already defined …

…simply callback rather than connecting again).
1 parent a8ca68f9
Showing with 11 additions and 7 deletions
...@@ -106,10 +106,10 @@ module.exports = (function() { ...@@ -106,10 +106,10 @@ module.exports = (function() {
} }
} else if (client) { } else if (client) {
client.query("SET TIME ZONE 'UTC'").on('end', function() { client.query("SET TIME ZONE 'UTC'").on('end', function() {
self.isConnected = true self.isConnected = true
self.client = client self.client = client
emitter.emit('success', done) emitter.emit('success', done)
}) })
} else { } else {
self.client = null self.client = null
emitter.emit('success', done) emitter.emit('success', done)
...@@ -121,9 +121,13 @@ module.exports = (function() { ...@@ -121,9 +121,13 @@ module.exports = (function() {
this.poolIdentifier = this.pg.pools.getOrCreate(this.sequelize.config) this.poolIdentifier = this.pg.pools.getOrCreate(this.sequelize.config)
this.poolIdentifier.connect(connectCallback) this.poolIdentifier.connect(connectCallback)
} else { } else {
//create one-off client if (!!this.client) {
this.client = new this.pg.Client(uri) connectCallback(null, this.client);
this.client.connect(connectCallback) } else {
//create one-off client
this.client = new this.pg.Client(uri)
this.client.connect(connectCallback)
}
} }
return emitter return emitter
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!