Skip to content
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

Multi-store transaction #6

Open
retorquere opened this issue Feb 11, 2024 · 5 comments
Open

Multi-store transaction #6

retorquere opened this issue Feb 11, 2024 · 5 comments
Assignees

Comments

@retorquere
Copy link

It doesn't look to be possible to create multi-store transactions. query opens a transaction on all stores when called without an argument, but fails on line 32, as objectStore doesn't accept an array argument.

@kennygomdori kennygomdori self-assigned this Feb 12, 2024
@kennygomdori
Copy link
Owner

I updated the description for query since it was not meant to be used with an Array of object store names.
Multiple requests across multiple object stores within a single transaction would be required only to call abort appropriately, but transactions are not exposed, so abort cannot be called when using query.
I have to implement a new method for this use case that doesn't involve a callback hell as in vanilla IndexedDB. I will try to figure something out soon.

@retorquere
Copy link
Author

Multiple requests across multiple object stores within a single transaction would be required only to call abort

I don't understand? IndexedDB allows opening a single transaction over two stores, update both, and then have the transaction commit, it's just that in the previous implementation of AsyncIndexedDB it was not possible. Why would you call abort in this scenario?

@retorquere
Copy link
Author

I'm trying a few implementations of IndexedDB promise-wrappers but I'm currently leaning towards my my own -- the space doesn't seem to have settled enough to have yielded a few that have wide usage (== battle-tested) except dexie, which is pretty large for what I want, and doesn't have async iterators. If you're actively using this lib I'm open to collaborating on it.

@kennygomdori
Copy link
Owner

The current implementation leverages the fact that you almost never need to explicitly call commit because a transaction automatically commits when the last request ends successfully. Having multiple requests in a single transaction is useful for scoping a transaction for rollback in case of a request failure or an explicit abort, but it shouldn't matter in other cases.

I am currently not using this lib because my job doesn't require me to work with IndexedDB anymore, and the job takes up almost all my time. I won't be able to work on it to expand it for the next month. But your gist looks promising though.

@retorquere
Copy link
Author

I don't intend to call commit -- hence the

have the transaction commit

as the transaction will automatically commit at the end of the microtask. But that still leaves the fact that multiple stores can be touched within a single all-or-nothing transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants