This repository was archived by the owner on Dec 19, 2019. It is now read-only.
Description Hello,
I was trying to use this against a redshift instance with the following test script:
const { Pool } = require ( 'pg' ) ;
const config = require ( './src/lib/config' ) ;
const credentials = config . get ( 'warehousedb' ) ;
const pool = new Pool ( {
user : credentials . user ,
host : credentials . host ,
database : credentials . name ,
password : credentials . pass ,
port : credentials . port
} ) ;
function consumeCursor ( cursor , cb , done ) {
console . log ( 'consumeCursor invocation' ) ;
cursor . read ( 100 , ( error , rows ) => {
if ( error ) {
done ( error ) ;
return ;
}
if ( rows . length < 1 ) {
console . log ( 'Cursor is empty, all done!' ) ;
done ( ) ;
return ;
}
cb ( rows ) ;
consumeCursor ( cursor , cb , done ) ;
} ) ;
}
const query = 'select * from <table_name> LIMIT 1000' ;
pool . connect ( ) . then ( function ( client ) {
console . log ( 'creating cursor' ) ;
const cursor = client . query ( new Cursor ( query ) ) ;
function done ( error ) {
if ( error ) {
console . error ( 'Cursor boom: ' , error ) ;
}
console . log ( 'done!' ) ;
cursor . close ( ( ) => client . release ( ) ) ;
}
function push ( result = [ ] ) {
console . log ( 'Got results: ' , result . length ) ;
}
consumeCursor ( cursor , push , done ) ;
} ) ;
and behold of the result:
creating cursor
consumeCursor invocation
Got results: 1000
consumeCursor invocation
Cursor is empty, all done!
done!
So here's what's confusing me:
As shown from Got results: 1000 I guess Redshift might not be playing ball?
Now, why Got results: 1000 if I'm asking to read 100 items? I tried removing the LIMIT 1000 as well but there was no change.
I haven't got any time yet to read node-pg-cursor yet so I def might be miss-understanding something, so apologie for something I might have missed.
Reactions are currently unavailable
Hello,
I was trying to use this against a redshift instance with the following test script:
and behold of the result:
So here's what's confusing me:
Got results: 1000I guess Redshift might not be playing ball?Got results: 1000if I'm asking to read 100 items? I tried removing theLIMIT 1000as well but there was no change.I haven't got any time yet to read
node-pg-cursoryet so I def might be miss-understanding something, so apologie for something I might have missed.