You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chilts edited this page Feb 23, 2013
·
2 revisions
node-postgres can maintain client pools internally. They are generally accessed via pg#wiki-method-connect but can be directly accessed & manipulated via pg.pools.
hash/object pg.pools.all
A hash of all existing client pools. A pool's key is built by calling JSON.stringify on the first parameter passed to pg.connect unless the first parameter is a callback, in which case JSON.stringify({}) is used.
####example
varpg=require('pg');console.log(Object.keys(pg.pools.all));//[]//connect using defaults or environment variables//will create a pool by the name of "{}"pg.connect(function(err,client,done){done();console.log(Object.keys(pg.pools.all));//["{}"]});
pg.pools.getOrCreate(object key)
Gets a pool by the given key or creates it if it does not yet exist. In either case it returns a modified instance of https://github.com/coopernurse/node-pool pre-configured to return Client instances.