Avocado
Avocado

Reputation: 901

Perform additional query at end of every transaction (pg-promise)

As a potential way of storing metadata about transactions, I would like to execute a query at end end of every transaction.

I have looked at adding logic inside the transact event, but there does not seem to be a way to make another request using the current transaction. Is there a way that this could be done using pg-promise? Is this an anti-pattern?

Upvotes: 1

Views: 112

Answers (1)

vitaly-t
vitaly-t

Reputation: 25840

You can only query against the transaction connection while inside a transaction callback. You cannot do it by handling transact event, it does not have the transaction connection available.

Upvotes: 2

Related Questions