Files
e-commerce/db/Pool.js
2022-07-05 19:12:14 -05:00

12 lines
385 B
JavaScript

const { Pool } = require('pg');
require('dotenv').config({ path: './config.env' });
const pool = new Pool({ connectionString: process.env.CONNECTION });
module.exports = {
// text = SQL query; params = array of values to inject
pool,
connect: async () => await pool.connect(),
query: (text, params) => pool.query(text, params),
end: async () => await pool.end()
}