'use strict';
var Pool = require('pg').Pool;
var config = Object.freeze({
user: 'foo',
password: 'secret',
database: 'my_db',
port: 5432
});
var pool = new Pool(config);
pool.connect(function(err, client, done) {
if(err) {
return console.error('error fetching client from pool', err);
}
console.log('done');
});
Also changing user input isn't good practice, because user can use options object later. So, I propose to clone options before adding new properties to it.
Pool constructor changes given
options
parameter https://github.com/brianc/node-pg-pool/blob/master/index.js#L13-L15 This doesn't work with frozen object. Next program terminates without error:Also changing user input isn't good practice, because user can use
options
object later. So, I propose to cloneoptions
before adding new properties to it.