This example shows an IDBOpenDBRequest.onupgradeneeded block that creates a new object store; it also includes onerror and onabort functions to handle non-success cases.
This example shows an IDBOpenDBRequest.onupgradeneeded block that creates a new object store; it also includes onerror and onabort functions to handle non-success cases.
This example shows an IDBOpenDBRequest.onupgradeneeded block that creates a new object store; it also includes onerror and onabort functions to handle non-success cases, and an onversionchange function to notify when a database structure change has occurred.
The indexedDB property of the IDBEnvironment interface provides a mechanism for applications to asynchronously access the capabilities of indexed databases.
In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. For a full working example, see our To-do Notifications app (view example live.)
If the database is successfully deleted, then a success event is fired on the request object returned from this method, with its result set to undefined. If an error occurs while the database is being deleted, then an error event is fired on the request object that is returned from this method.
IDBIndex interface of the IndexedDB API provides asynchronous access to an index in a database. An index is a kind of object store for looking up records in another object store, called the referenced object store. You use this interface to retrieve data.
If a value is successfully found, then a structured clone of it is created and set as the result of the request object: this returns the record the key is associated with.
There is a performance cost associated with looking at the value property of a cursor, because the object is created lazily. To use a feature like getAll(), Gecko would have to create all the objects at once. If you were just interested in looking at each of the keys, for instance, it would be much more efficient to use a cursor. If you were trying to get an array of all the objects in an object store, though, you could use getAll().
If a key is successfully found it is set as the result of the request object: this returns the primary key of the record the key is associated with, not the whole record as IDBIndex.get does.
The isAutoLocale read-only property of the IDBIndex interface returns a Boolean indicating whether the index had a locale value of auto specified upon its creation (see createIndex()'s optionalParameters.)