pg-instance.js 383 B

1234567891011121314151617
  1. const pgp = require('pg-promise')();
  2. // 连接到数据库
  3. var PgInstanse;
  4. const pgClient = function(){
  5. if(!PgInstanse){
  6. PgInstanse = pgp({
  7. user: 'postgres',
  8. password: 'postgres',
  9. host: 'localhost',
  10. port: 25432,
  11. database: 'postgres'
  12. });
  13. }
  14. return PgInstanse;
  15. }
  16. module.exports.pgClient = pgClient