mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
20 lines
475 B
TypeScript
20 lines
475 B
TypeScript
import * as QueryStream from 'pg-query-stream';
|
|
import * as pg from 'pg';
|
|
|
|
const options: QueryStream.Options = {
|
|
highWaterMark: 1000,
|
|
batchSize: 100
|
|
};
|
|
|
|
const query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000], options);
|
|
|
|
pg.connect('', (err, client, done) => {
|
|
const stream = client.query(query);
|
|
stream.on('end', () => {
|
|
client.end();
|
|
});
|
|
stream.on('data', (data: any) => {
|
|
console.log(data);
|
|
});
|
|
});
|