Skip to content

Commit f475ac2

Browse files
committed
Take arbitrary node-postgres config, not just a string
1 parent 3008c2a commit f475ac2

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

index.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ var pg = require('pg')
55

66
function PostgresDB(options) {
77
if (!(this instanceof PostgresDB)) return new PostgresDB(options);
8-
if (typeof options === 'string') {
9-
options = {
10-
url: options
11-
}
12-
}
138
DB.call(this, options);
149

1510
this.closed = false;
1611

17-
this.pg_url = options.url;
12+
this.pg_config = options;
1813
};
1914
module.exports = PostgresDB;
2015

@@ -45,7 +40,7 @@ PostgresDB.prototype.commit = function(collection, id, op, snapshot, callback) {
4540
* }
4641
* snapshot: PostgresSnapshot
4742
*/
48-
pg.connect(this.pg_url, function(err, client, done) {
43+
pg.connect(this.pg_config, function(err, client, done) {
4944
if (err) {
5045
done(client);
5146
callback(err);
@@ -130,7 +125,7 @@ PostgresDB.prototype.commit = function(collection, id, op, snapshot, callback) {
130125
// snapshot). A snapshot with a version of zero is returned if the docuemnt
131126
// has never been created in the database.
132127
PostgresDB.prototype.getSnapshot = function(collection, id, fields, callback) {
133-
pg.connect(this.pg_url, function(err, client, done) {
128+
pg.connect(this.pg_config, function(err, client, done) {
134129
if (err) {
135130
done(client);
136131
callback(err);
@@ -180,7 +175,7 @@ PostgresDB.prototype.getSnapshot = function(collection, id, fields, callback) {
180175
//
181176
// Callback should be called as callback(error, [list of ops]);
182177
PostgresDB.prototype.getOps = function(collection, id, from, to, callback) {
183-
pg.connect(this.pg_url, function(err, client, done) {
178+
pg.connect(this.pg_config, function(err, client, done) {
184179
if (err) {
185180
done(client);
186181
callback(err);

0 commit comments

Comments
 (0)