refactored for pg pool

This commit is contained in:
Mikayla Dobson
2022-07-05 11:59:37 -05:00
parent f54b4fc5d6
commit f1d964b092
8 changed files with 85 additions and 87 deletions

View File

@@ -1,9 +0,0 @@
const { Client } = require('pg');
require('dotenv').config({ path: './config.env' });
const connectionString = process.env.CONNECTION;
const client = () => {
return new Client(connectionString);
}
module.exports = client;

View File

@@ -5,7 +5,7 @@ const pool = new Pool({ connectionString: process.env.CONNECTION });
module.exports = {
// text = SQL query; params = array of values to inject
connect: async () => await pool.connect(),
connect: async () => await pool.connect().then(console.log("Connection successful.")),
query: (text, params) => pool.query(text, params),
end: async () => await pool.end()
}