Re: [w3c/IndexedDB] Add a new event `onbeforecommit` on the interface IDBTransaction (#314)

Here is my usage:

(I'm using the library `idb` to wrap raw indexeddb as Promise version)
```ts
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:

```ts
async function consistentDBWriteAccess(action: (t: TransactionType) => Promise<void>) {
    const t = (await db()).transaction(['objectStore'], 'readwrite')
    await action(t)
    await assertDBConsistency(t)
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/314#issuecomment-567310434

Received on Thursday, 19 December 2019 03:06:00 UTC