I have a query within a transaction to create a record in the database. Something like that:
const trx = await Database.beginTransaction() // ... await Request.create(data, trx) // ... await trx.commit()
But I have a
afterSave hook in this same model (
Request model), and apparently this causes the transaction never to end, causing a timeout error.
If I add the transaction with the
afterSave hook, I get the timeout problem. But if I remove the transaction or the
afterSave hook, I don’t get the error. But they don’t work together.
How can I have the transaction and the
afterSave hook working together?