refactored for pg pool
This commit is contained in:
@@ -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;
|
||||
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user