connect-pg icon indicating copy to clipboard operation
connect-pg copied to clipboard

Correct example for new version of node-postgres

Open tcrimi opened this issue 12 years ago • 4 comments

As of version 1.0 of node-postgres, the pg.connect callback now returns a 'done' callback which one needs to use to return the client object to the connection pool.

var pg = require('pg');

function pgConnect (callback) {
    pg.connect('tcp://nodepg:password@localhost/pgstore',
        function (err, client, done) {
            if (err) {
                console.log(JSON.stringify(err));
            }
            if (client) {
                callback(client);
                done();
            }
        }
    );
};

tcrimi avatar Apr 17 '13 21:04 tcrimi

Give me a little time to look at the code. Personal life interfering with productive coding.

jebas avatar May 07 '13 10:05 jebas

Any progress on this ?

postsql avatar Jan 19 '14 23:01 postsql

https://github.com/jebas/connect-pg/pull/5

abhishekmunie avatar Feb 03 '14 16:02 abhishekmunie

+1 The above code works, the example in Readme.md not. Readme.md should be updated.

jansc avatar Jun 11 '14 12:06 jansc