feat: add `db` util w/ pool

pull/2572/head
Luke Edwards 7 years ago
parent e8adc9c0ab
commit d6f0b69b72

@ -21,6 +21,7 @@
"golden-fleece": "^1.0.9",
"limax": "^1.7.0",
"marked": "^0.6.1",
"pg": "^7.10.0",
"polka": "^1.0.0-next.2",
"prismjs": "^1.15.0",
"sirv": "^0.4.0"

@ -0,0 +1,15 @@
import { Pool } from 'pg';
const { DATABASE_URL } = process.env;
export const DB = new Pool({
connectionString: process.env.DATABASE_URL
});
export function query(text, values=[]) {
return DB.query(text, values).then(r => r.rows);
}
export function find(text, values=[]) {
return query(text, values).then(arr => arr[0]);
}
Loading…
Cancel
Save