This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We can handle things more gracefully in `db.onversionchange`, prompt the visitor to save the data before the connection is closed and so on.
Or, an alternative approach would be to not close the database in `db.onversionchange`, but instead use the `onblocked` handler (in the new tab) to alert the visitor, tell him that the newer version can't be loaded until they close other tabs.
Or, an alternative approach would be to not close the database in `db.onversionchange`, but instead use the `onblocked` handler (in the new tab) to alert the visitor, telling them that the newer version can't be loaded until they close other tabs.
These update collisions happen rarely, but we should at least have some handling for them, at least an `onblocked` handler, to prevent our script from dying silently.
Expand Down
Expand Up
@@ -381,7 +381,7 @@ But it will be even better, if we'd like to keep the operations together, in one
First, make `fetch`, prepare the data if needed, afterwards create a transaction and perform all the database requests, it'll work then.
To detect the moment of successful completion, we can listen to `transaction.oncomplete` event:
To detect the moment of successful completion, we can listen to the `complete` event:
```js
let transaction = db.transaction("books", "readwrite");
Expand All
@@ -401,7 +401,7 @@ To manually abort the transaction, call:
transaction.abort();
```
That cancels all modification made by the requests in it and triggers `transaction.onabort` event.
This will cancel all modifications made by requests in the transaction, and fire the `abort` event.
## Error handling
Expand Down
Expand Up
@@ -668,7 +668,8 @@ let request = store.openCursor(query, [direction]);
- `"prev"` -- the reverse order: down from the record with the biggest key.
- `"nextunique"`, `"prevunique"` -- same as above, but skip records with the same key (only for cursors over indexes, e.g. for multiple books with price=5 only the first one will be returned).
**The main difference of the cursor is that `request.onsuccess` triggers multiple times: once for each result.**
**The main difference of the cursor is that the `request.onsuccess` handler is called multiple times: once for each result.**
Here's an example of how to use a cursor:
Expand Down
Expand Up
@@ -760,14 +761,13 @@ So we have all the sweet "plain async code" and "try..catch" stuff.
If we don't catch an error, then it falls through, till the closest outer `try..catch`.
An uncaught error becomes an "unhandled promise rejection" event on `window` object.
An uncaught error fires an `unhandledrejection` event (unhandled promise rejection) on the `window` object.
let request = event.target; // IndexedDB native request object
let error = event.reason; // Unhandled error object, same as request.error
let error = event.reason; // The unhandled error object that caused the promise rejection
...report about the error...
});
```
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: correct terms in indexeddb article.md en #3984
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
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
fix: correct terms in indexeddb article.md en #3984
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing