pg-instance.js 405 B

1234567891011121314151617
  1. const pgp = require('pg-promise')();
  2. // 连接到数据库
  3. var PgInstanse;
  4. export const pgClient = function(){
  5. let pgConns = global.config['DATABASE_DBNAME']
  6. if(global.config['LOCAL']) {
  7. pgConns = `postgres://postgres:postgres@127.0.0.1:25432/postgres`
  8. }
  9. if(!PgInstanse){
  10. // console.log(pgconfig)
  11. PgInstanse = pgp(pgConns);
  12. }
  13. return PgInstanse;
  14. }