由于PG.Connect已被弃用,使用PG-Promise会很好吗? 请查看我的代码,让我知道是否还有其他解决方案。
var express = require('express');
var app = express();
const pgp = require('pg-promise')();//pg promise
var connectionString = "";
var parse = require('pg-connection-string').parse;
try {
var connectionString = "postgres://USERNAME:@localhost:5432/DBNAME";
var config = parse(connectionString);
config.password = "Password"; //Setting the password later since we are
getting it from some encryption service
var dbcon = pgp(config);
app.set('dbCon', dbcon);
}
catch (error) {
console.log("DB error")
}
module.exports = app;