-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new event onbeforecommit
on the interface IDBTransaction
#314
Comments
Can you give examples of the problems you are trying to address with this idea? Where have you seen the lack of this functionality be a problem? |
Also, would the discussion in #34 which allow for explicit control over transaction lifetime handle this? |
Here is my usage: (I'm using the library const t = getTransaction('objectStore', 'readwrite')
await doDangerousAction1(t)
await doDangerousAction2(t) I need a way to do a data consistency check before the transaction end. If the check failed, I want to drop the transaction to prevent my db goes into a inconsistent state. Currently I use this way to do the job: async function consistentDBWriteAccess(action: (t: TransactionType) => Promise<void>) {
const t = (await db()).transaction(['objectStore'], 'readwrite')
await action(t)
await assertDBConsistency(t)
} |
It will be nicer to append the check like this: function doDangerousAction1(t) {
// ....
t.addEventListener('beforecommit', e => assertDBConsistency(e, t))
} Therefore I can enforce a consistency check before the transaction commit then abort the transaction if it goes into a invalid state. |
It will also be nice to have a |
TPAC 2024: We discussed and believe that explicit control over transaction lifetime should support the scenarios discussed by this issue. I'm closing this issue, but please re-activate with example scenarios if we're mistaken. |
By adding a
onbeforecommit
event, developers can suppress the bad transaction that make the db in an inconsistent state to be committed.e.g.
The text was updated successfully, but these errors were encountered: