colouring-montreal/app/src/db.js

25 lines
624 B
JavaScript
Raw Normal View History

/**
* Expose query interface to database pool
*
* - connection details must be set in environment variables, default to:
* PGHOST='localhost'
* PGUSER=process.env.USER
* PGDATABASE=process.env.USER
* PGPASSWORD=null
* PGPORT=5432
*/
2018-09-30 11:17:31 -04:00
import pg from 'pg-promise';
2018-09-30 11:17:31 -04:00
// pg-promise, can provide initialisation options
const pgp = pg();
2018-09-30 15:27:53 -04:00
// database connection (default to env vars)
const db = pgp({
'host': process.env.PGHOST,
'dbname': process.env.PGDATABASE,
'user': process.env.PGUSER,
'password': process.env.PGPASSWORD,
'port': process.env.PGPORT
});
2018-09-30 11:17:31 -04:00
export default db;