pg-rest-api/src/service/db.js

25 lines
489 B
JavaScript

const DEBUG=require('debug')('debug');
DEBUG('db start...');
const { Pool } = require('pg');
const config = require('../config');
const pool = new Pool(config.db);
/**
* Query the database using the pool
* @param {*} query
* @param {*} params
*
* @see https://node-postgres.com/features/pooling#single-query
*/
async function query(query, params) {
const {rows, fields} = await pool.query(query, params);
return rows;
}
module.exports = {
query
}
DEBUG('db done.');