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.
master
jaweesner 7 years ago committed by GitHub
parent e15feb199a
commit 455e170084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);

Loading…
Cancel
Save