node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

Get fields from query stream

Open ZeRego opened this issue 2 years ago • 1 comments

Copy of this issue from the legacy repository https://github.com/brianc/node-pg-query-stream/issues/51

When using pg-query-stream is there a way to get the field description at the beginning or end of the stream?

ZeRego avatar Jun 19 '23 10:06 ZeRego

You can do this:

const query = new QueryStream('SELECT * FROM SOMETHING')
const stream = client.query(query)
client.connection.once('rowDescription', (fields) => {
  
})

The stream itself doesn't emit the row description event, but the connection (kinda lower level thing inside the client) does.

brianc avatar Sep 01 '23 17:09 brianc