Updated readme examples to es6 (#36)

This commit is contained in:
Amila Welihinda 2019-01-08 06:55:35 -08:00 committed by Brian C
parent 6177ff95a6
commit c999aae6af

View File

@ -18,15 +18,15 @@ _requires pg>=2.8.1_
## use
```js
var pg = require('pg')
var QueryStream = require('pg-query-stream')
var JSONStream = require('JSONStream')
const pg = require('pg')
const QueryStream = require('pg-query-stream')
const JSONStream = require('JSONStream')
//pipe 1,000,000 rows to stdout without blowing up your memory usage
pg.connect(function(err, client, done) {
if(err) throw err;
var query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000])
var stream = client.query(query)
pg.connect((err, client, done) => {
if (err) throw err;
const query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000])
const stream = client.query(query)
//release the client when the stream is finished
stream.on('end', done)
stream.pipe(JSONStream.stringify()).pipe(process.stdout)