postgre sql connect

This commit is contained in:
Jan Prochazka
2020-01-01 19:54:10 +01:00
parent 4da867e725
commit 0119d1839f
3 changed files with 114 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
const { Client } = require('pg');
module.exports = async function connect({ server, port, user, password }) {
const client = new Client({ host: server, port, user, password, database: 'postgres' });
await client.connect();
const res = await client.query('SELECT version()');
const { version } = res.rows[0];
await client.end();
return { version };
};