由于PG.Connect已被弃用,因此使用PG-Promise是否很好?

时间:2018-07-17 06:14:59

标签: massivejs

由于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;

0 个答案:

没有答案