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

Commit b5091e0c by sdepold

moved postgres connection uri generation into query-generator

1 parent 7b10c4af
......@@ -44,18 +44,10 @@ module.exports = (function() {
this.isConnecting = true
this.isConnected = false
var conStr = '<%= protocol %>://<%= user %>:<%= password %>@<%= host %><% if(port) { %>:<%= port %><% } %>/<%= database %>';
conStr = Utils._.template(conStr)({
user: this.config.username,
password: this.config.password,
database: this.config.database,
host: this.config.host,
port: this.config.port,
protocol: this.config.protocol,
})
var pg = require("pg")
, uri = this.sequelize.getQueryInterface().QueryGenerator.databaseConnectionUri(this.config)
var pg = require("pg")
this.client = new pg.Client(conStr)
this.client = new pg.Client(uri)
this.client.connect(function(err, client) {
self.isConnecting = false
......
var Utils = require("../../utils")
, util = require("util")
, util = require("util")
, tables = {}
, primaryKeys = {};
......@@ -380,6 +380,19 @@ module.exports = (function() {
})
return Utils._.compact(fields)
},
databaseConnectionUri: function(config) {
var template = '<%= protocol %>://<%= user %>:<%= password %>@<%= host %><% if(port) { %>:<%= port %><% } %>/<%= database %>';
return Utils._.template(template)({
user: config.username,
password: config.password,
database: config.database,
host: config.host,
port: config.port,
protocol: config.protocol
})
}
}
......
......@@ -20,6 +20,5 @@ module.exports = (function() {
return this
}
return Query
})()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!