I’m creating a app that connects to an external database (postgres), using node-postgres lib.
I created the connection outside the events, but the same connection is not used when the event is called again, as show in the image (prisma_test database):
Hey Felipi,
So the problem you are facing is that, you are creating a connection pool and trying to re-use the a connection from the pool for each of the events. But each of the new invocation of events, seems to create a new connection rather than using already created connection from pool.
The reason for the happening is, each of the events are triggered independent and in a separate instance. Hence, during each invocation a new connection pool is created and a connection object is assigned from the pool. So, we would recommend to use a single connection for each of the event handler.