Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const pg = require('pg');
- const pool = new pg.Pool({
- host:'localhost',
- port:5432,
- database:'NODE2906',
- user:'postgres',
- password:1,
- idleTimeoutMillis:1000,
- max: 20
- });
- function QueryDB(sql, arrayData){
- return new Promise((resolve, roject)=>{
- pool.connect( (err, client, done) =>{
- if(err) return roject(err);
- client.query(sql,(err, result)=>{
- done();
- if(err) return roject(err);
- resolve(result.rows);
- });
- });
- });
- }
- // QueryDB('SELECT * FROM "Product"',[])
- // .then(result => console.log(result.rows))
- // .catch(err => console.log(err));
- module.exports = QueryDB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement