Files
inventory/inventory-server/src/utils/db.js
2026-01-30 22:24:50 -05:00

21 lines
324 B
JavaScript

const { Pool } = require('pg');
let pool;
function initPool(config) {
pool = new Pool(config);
return pool;
}
async function getConnection() {
if (!pool) {
throw new Error('Database pool not initialized');
}
return pool.connect();
}
module.exports = {
initPool,
getConnection,
getPool: () => pool
};