Add afterCommit
hooks for globals, fields, and collections
#13719
Replies: 3 comments 3 replies
-
I agree such a hook would be useful. In the meantime, you could use the job queue for this. In your afterChange hook, you can call
That's true - using this workaround, you'll have to rely on the speed of your job queue autoRun configuration.
Using this workaround, if the transaction fails, the job won't be added to the queue as the job document creation will be rolled back. |
Beta Was this translation helpful? Give feedback.
-
Can nextjs after function be used for this? 🤔 |
Beta Was this translation helpful? Give feedback.
-
I think for consitency and interoperability with non-transaction situations, the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, there is no way to fire off some code immediately after data is committed to the database. This missing feature is useful for tasks where it's important that the APIs are returning the new data and not the old. Examples:
The Job Queue serves a similar function, but it doesn't have a way to fire off the delayed action immediately after the transation is complete, and if the transaction fails from a later hook, the job can't know this.
Beta Was this translation helpful? Give feedback.
All reactions