Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

fix: wrap operations in transactions #7

Closed
wants to merge 9 commits into from

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Jun 9, 2020

To get a cursor to operate over a set of keys from an idb store, you
have to start a transaction. That transaction will remain open as long
as there are tasks in the microtask queue - when it empties the
transaction is automatically closed.

Transactions operate on an ObjectStore, puts and gets not to the object
store also seem to close the transaction.

This change adds a _getStore method to the datastore which
creates a new transaction if there was no previous transaction, or if
the previous transaction was closed. All operations then take place as
part of this transaction.

To get a cursor to operate over a set of keys from an idb store, you
have to start a transaction. That transaction will remain open as long
as there are tasks in the microtask queue - when it empties the
transaction is automatically closed.

Transactions operate on an ObjectStore, puts and gets not to the object
store also seem to close the transaction.

This change adds a `_getObjectStore` method to the datastore which
creates a new transaction if there was no previous transation, or if
the previous transaction was closed.  All operations then take place as
part of this transaction.
@achingbrain achingbrain force-pushed the fix/wrap-operations-in-transaction branch from 57522e9 to 807e425 Compare June 10, 2020 11:07
@achingbrain
Copy link
Member Author

@achingbrain achingbrain force-pushed the fix/wrap-operations-in-transaction branch from fb5bed4 to 5c7f97b Compare June 10, 2020 17:13
@autonome autonome added status/blocked Unable to be worked further until needs are met status/in-progress In progress and removed status/blocked Unable to be worked further until needs are met labels Jul 2, 2020
@achingbrain achingbrain marked this pull request as draft July 9, 2020 14:16
@achingbrain
Copy link
Member Author

We still need something like this to fix ipfs/js-stores#198 but this PR is now really out of date

@achingbrain achingbrain deleted the fix/wrap-operations-in-transaction branch March 14, 2023 19:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

datastore-idb .query doesn't work as expected
2 participants