node-postgres
node-postgres copied to clipboard
pg-cursor not work!!
const { Pool } = require('pg')
const Cursor = require('pg-cursor')
const pool = new Pool({
user: 'xxxx',
password: 'xxxxx',
database: 'xxxxx',
host: 'xxxxx',
port: 8080,
max: 20, //default 10
})
setTimeout(async () => {
const client = await pool.connect()
const text = 'SELECT * FROM dim_app'
const cursor = client.query(new Cursor(text))
cursor.read(3, (err, rows) => {
console.log('--->', rows, rows.length)
cursor.close(() => {
client.release()
})
});
}, 100);
HI,here is my test code.
The dim_app table which from AWS Redshift contains 100 items,I just want to test pg-cursor with getting 3 by cursor,but I always get 100 in the response.
Anyone can help? Thanks a lot.