File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -27,11 +27,13 @@ class QueryStream extends Readable implements Submittable {
2727
2828 super ( { objectMode : true , autoDestroy : true , highWaterMark : batchSize || highWaterMark } )
2929 this . cursor = new Cursor ( text , values , config )
30- this . cursor . on ( 'end' , ( result ) => {
31- this . callback && this . callback ( null , result )
32- } ) . on ( 'error' , ( err ) => {
33- this . callback && this . callback ( err )
34- } )
30+ this . cursor
31+ . on ( 'end' , ( result ) => {
32+ this . callback && this . callback ( null , result )
33+ } )
34+ . on ( 'error' , ( err ) => {
35+ this . callback && this . callback ( err )
36+ } )
3537
3638 // delegate Submittable callbacks to cursor
3739 this . handleRowDescription = this . cursor . handleRowDescription . bind ( this . cursor )
Original file line number Diff line number Diff line change 1+ import assert from 'assert'
2+ import { Pool } from 'pg'
3+ import QueryStream from '../src'
4+
5+ describe ( 'pool' , function ( ) {
6+ it ( 'works' , async function ( ) {
7+ const pool = new Pool ( )
8+ const query = new QueryStream ( 'SELECT * FROM generate_series(0, 10) num' , [ ] )
9+ const q = pool . query ( query )
10+ console . log ( q ) // Promise { <pending>, ...
11+ query . on ( 'data' , ( row ) => {
12+ // just consume the whole stream
13+ } )
14+ await q //!
15+ query . on ( 'end' , ( ) => {
16+ pool . end ( )
17+ } )
18+ } )
19+ } )
You can’t perform that action at this time.
0 commit comments