mirror of
https://github.com/seejohnrun/haste-server.git
synced 2024-11-24 13:31:21 +00:00
Get the client working as expected with pg 8
This commit is contained in:
parent
3a17c86a0f
commit
9a692ed652
1 changed files with 12 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*global require,module,process*/
|
/*global require,module,process*/
|
||||||
|
|
||||||
var postgres = require('pg');
|
|
||||||
var winston = require('winston');
|
var winston = require('winston');
|
||||||
|
const {Client} = require('pg');
|
||||||
|
|
||||||
// create table entries (id serial primary key, key varchar(255) not null, value text not null, expiration int, unique(key));
|
// create table entries (id serial primary key, key varchar(255) not null, value text not null, expiration int, unique(key));
|
||||||
|
|
||||||
|
@ -64,13 +64,17 @@ PostgresDocumentStore.prototype = {
|
||||||
|
|
||||||
// A connection wrapper
|
// A connection wrapper
|
||||||
safeConnect: function (callback) {
|
safeConnect: function (callback) {
|
||||||
postgres.connect(this.connectionUrl, function (err, client, done) {
|
const client = new Client({connectionString: this.connectionUrl});
|
||||||
if (err) {
|
const connectionPromise = client.connect();
|
||||||
winston.error('error connecting to postgres', { error: err });
|
|
||||||
callback(err);
|
const done = () => {};
|
||||||
} else {
|
|
||||||
callback(undefined, client, done);
|
connectionPromise.then(() => {
|
||||||
}
|
callback(undefined, client, done);
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
winston.error('error connecting to postgres', {error});
|
||||||
|
callback(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue