Query events with Pool
See original GitHub issueWith a client we can use the “row” event of a query.
client.query("select id from table").on("row", row => console.log(row))
{ id: 1 }
{ id: 2 }
{ id: 3 }
{ id: 4 }
{ id: 5 }
But with a pool we can’t do this.
pool.query("select id from table").on("row", row => console.log(row))
TypeError: pool.query(...).on is not a function
Is it possible to use the query events with pool?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Query Event DB to find who has connected to a pool...
Hi all,. I need to get a list of users that have connected to a certain pool over the last 2 weeks in...
Read more >Using SQL Server Extended Events to monitor query ...
In this article, we will explore how we can use SQL Server extended events to monitor query performance in SQL Server.
Read more >Need query for Getting the Status of a particular app pool in IIS
Hi, Can you share the query to identify when a particular IIS application pool stopped/crashed via Log Analytics. Thanks RC.
Read more >pg.Pool – node-postgres
The pool will dispatch every query passed to pool.query on the first available idle client. Transactions within PostgreSQL are scoped to a single...
Read more >Connection terminated unexpectedly does not propagate to ...
Always use a pool, always add an error event listener to the pool. Not emitting the event when there's an active query doesn't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The pool supports returning a client if you want to do something like that:
That API ^^ has existed for years and is still there. 😄
pool.query
is a helper method for the most common operation which is “I want to run a query and get the rows back.” If you want to do something “fancier” with a client (transactions, row events, listen/notify, pg-query-stream, etc) thenpool.query
isn’t for you. I don’t really want to extend thepool.query
method with even more functionality…Curious: why are you using
query.on('row')
in the first place?@brianc Thanks for the clarification, that really makes sense. A quick question about the exact semantics: When using
client.on('notification', callback)
on a client acquired from a pool, is it safe to release this client back to the pool and still get notify updates, or does this require holding on to the client indefinitely?