From 455e170084b4c4042efeef126c6dc1d31788bc8d Mon Sep 17 00:00:00 2001 From: jaweesner <34662212+jaweesner@users.noreply.github.com> Date: Thu, 12 Apr 2018 19:36:09 -0700 Subject: [PATCH] Update to be pq 7.0 compilant pg singletons are no longer supported according to https://node-postgres.com/guides/upgrading , updated example to reflect upgrade changes. --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 820986c..0f63fd2 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,12 @@ If you're not familiar with the feature (I wasn't either) you can read this for ### pipe from a table to stdout ```js -var pg = require('pg'); +var {Pool} = require('pg'); var copyTo = require('pg-copy-streams').to; -pg.connect(function(err, client, done) { +var pool = new Pool(); + +pool.connect(function(err, client, done) { var stream = client.query(copyTo('COPY my_table TO STDOUT')); stream.pipe(process.stdout); stream.on('end', done); @@ -35,10 +37,12 @@ pg.connect(function(err, client, done) { ```js var fs = require('fs'); -var pg = require('pg'); +var {Pool} = require('pg'); var copyFrom = require('pg-copy-streams').from; -pg.connect(function(err, client, done) { +var pool = new Pool(); + +pool.connect(function(err, client, done) { var stream = client.query(copyFrom('COPY my_table FROM STDIN')); var fileStream = fs.createReadStream('some_file.tsv') fileStream.on('error', done);