An afterCommit
hook can be added to both managed and unmanaged transaction objects:
afterCommit
hooks are not raised if a transaction is rolled back
You can use the afterCommit
hook in conjunction with model hooks to know when a instance is saved and available outsideof a transaction
model.afterSave((instance, options) => {
// notify listeners the instance has been saved
options.transaction.afterCommit(() => /* Notify */)
}
// Save done outside a transaction, safe for callers to fetch the updated model