The new version of pg , namely 7.0.0, was published about 15 hours ago (since the writing of this article).
There are many changes in this version, one of which is that pg.connect was deprecated (in other words: removed) in favor of pg.Pool(...).connect(...) , as described here: https: / /node-postgres.com/guides/upgrading
The new connection method is as follows:
var pool = new pg.Pool() // connection using created pool pool.connect(function(err, client, done) { client.query(/* etc, etc */) done() }) // pool shutdown pool.end()
Many old documents do not reflect these changes, so the sample code that they use will no longer work.
You can either try or rewrite the example code to work in 7.0.0, or explicitly install an older version that will work with sample code:
npm install pg@6
robertklep
source share