This document defines APIs for a database of records holding simple values and hierarchical objects. Each record consists of a key and some value. Moreover, the database maintains indexes over records it stores. An application developer directly uses an API to locate records either by their key or by using an index. A query language can be layered on this API. An indexed database can be implemented using a persistent B-tree data structure.

Indexed Database API

Asynchronous APIs

The asynchronous API methods return without blocking the calling thread. All asynchronous operations immediately return an IDBRequest instance. This object does not initially contain any information about the result of the operation. Once information becomes available, an event is fired on the request and the information becomes available through the properties of the IDBRequest instance.

The IDBRequest Interface

The IDBRequest interface provides means to access results of asynchronous requests to databases and database objects using event handler attributes [[!DOM-LEVEL-3-EVENTS]].

In the following example, we open a database asynchronously. Various event handlers are registered for responding to various situations.

var request = indexedDB.open('AddressBook', 15); request.onsuccess = function(evt) {...}; request.onerror = function(evt) {...};
readonly attribute any result
When the done flag is true, getting this property MUST return the result of the request. This is undefined when the request resulted in an error. When the done flag is false, getting this property MUST throw a DOMException of type InvalidStateError.
InvalidStateError
Thrown when this attribute was read when the done flag was set to false.
readonly attribute DOMError error
When the done flag is true, getting this property MUST return the error of the request. This is null when no error occurred. When the done flag is false, getting this property MUST throw a DOMException of type InvalidStateError.
InvalidStateError
Thrown when this attribute was read when the done flag was set to false.
readonly attribute object source
Getting this property MUST return the source for the request. Returns null when there is no source set.
readonly attribute IDBTransaction transaction
Getting this property MUST return the transaction for the request. This property can be null for certain requests, such as for request returned from IDBFactory.open.
readonly attribute enum readyState
When the done flag is false, returns "pending", otherwise returns "done".
[TreatNonCallableAsNull] attribute Function? onsuccess
The event handler for the success event
[TreatNonCallableAsNull] attribute Function? onerror
The event handler for the error event

When a request is made, a new request is returned with its readyState set to "pending". If a request completes successfully, the readyState is changed to "done", the result is set to the result of the request, and an event with type success is fired at the request.

If an error occurs while performing the operation, the readyState is changed to "done", the error attribute is set to a DOMError type that matches the error, and an event with type error is fired at the request.

The open and deleteDatabase functions on IDBFactory uses a separate interface for its requests in order to make use of the blocked event and upgradeneeded event easier.

[TreatNonCallableAsNull] attribute Function? onblocked
The event handler for the blocked event
[TreatNonCallableAsNull] attribute Function? onupgradeneeded
The event handler for the upgradeneeded event

The task source for these tasks is the database access task source.

Event interfaces

This specification fires events with the following custom interfaces:

readonly attribute unsigned long long oldVersion
Returns the old version of the database.
readonly attribute unsigned long long? newVersion
Returns the new version of the database. See the steps for running a "versionchange" transaction.

Events are constructed as defined in Constructing events, in [[!DOM4]].

Opening a database

Window and WorkerUtils objects MUST implement the IDBEnvironment interface.

readonly attribute IDBFactory indexedDB
This attribute provides applications a mechanism for accessing capabilities of indexed databases.

Every method for making asynchronous requests returns an IDBRequest object that communicates back to the requesting application through events. This design means that any number of requests can be active on any database or object handle at a time.

IDBOpenDBRequest open()

When invoked, this method MUST create a request and return it. The created request MUST implement the IDBOpenDBRequest interface and have its source set to null. The method then queues up an operation to run the steps for opening a database. Let origin be the origin of the IDBEnvironment used to access this IDBFactory, name and version be the name and version parameters passed to this function, and request be the newly created request.

If no version is specified and a database exists, use the current database version and follow the steps for opening a database. If no version is specified and no database exists, set database version to 1, follow the steps for opening a database, and return a database without object stores.

If an error is returned from the steps above, the implementation MUST set the error attribute of the request to a DOMError whose name is the same as the error returned, and dispatch an event at the request. The event must use the Event interface and have its type set to "error". The event does bubble but is not cancelable. The propagation path of the event is just the request.

If the steps above are successful, the implementation MUST set the result to the connection created by the steps above and dispatch an event at request. The event must use the Event interface and have its type set to "success". The event does not bubble and is not cancelable. The propagation path of the event is just the request. If the steps above resulted in a "versionchange" transaction being run, then firing the "success" event MUST be done after the “versionchange” transaction completes.

The last requirement is to ensure that in case another version upgrade is about to happen, the success event is fired on the connection first so that the page gets a chance to register a listener for the versionchange event.

The firing of "success" or "error" events do not follow the normal steps to fire a success event or fire an error event as there is no active transaction at the time when they fire.

DOMString name
The name for the database
[EnforceRange] optional unsigned long long version
The version for the database
TypeError
The value of version is 0 (zero) or a negative number.
IDBOpenDBRequest deleteDatabase()

When invoked, this method MUST create a request and return it. The created request must implement the IDBOpenDBRequest interface and have its source set to null. The method then queues up an operation to run the steps for deleting a database. Let origin be the origin of the IDBEnvironment used to access this IDBFactory and name be the name parameter passed to this function.

If an error is returned from the steps above, the implementation MUST set the error attribute of the request to a DOMError whose name is the same as the error returned, and dispatch an event at the request. The event must use the Event interface and have its type set to "error". The event does bubble but is not cancelable. The propagation path of the event is just the request.

If the steps above are successful, the implementation MUST set the result of the request to undefined and fire a success event at the request. The event MUST implement the IDBVersionChangeEvent interface and have oldVersion set to database version and have the newVersion property set to null.

The firing of "success" or "error" events do not follow the normal steps to fire a success event or fire an error event as there is no active transaction at the time when they fire.

DOMString name
The name for the database
short cmp()

When invoked, this method MUST compare two keys. The method returns 1 if the first key is greater than the second, -1 if the first is less than the second, and 0 if the first is equal to the second.

any first
The first key to compare.
any second
The second key to compare.
DataError
One of the supplied keys was not a valid key.

Database

A database object can be used to manipulate the objects of that database. It is also the only way to obtain a transaction for that database.

readonly attribute DOMString name
On getting, this attribute MUST return the name of the connected database. The function MUST return this name even if the closePending flag is set on the connection. In other words, the return value from this function stays constant for the lifetime of the IDBDatabase instance.
readonly attribute unsigned long long version
On getting, this attribute MUST return the version of the database when this IDBDatabase instance was created. When a IDBDatabase instance is created, this is always the number passed as the version argument passed to the open call used to create the IDBDatabase instance. This value remains constant for the lifetime of the IDBDatabase object. If the connection is closed, this attribute represents a snapshot of the version that the database had when the connection was closed. Even if another connection is later used to modify the version, that attribute on closed instances are not changed.
readonly attribute DOMStringList objectStoreNames
On getting, this attribute MUST return a list of names of the object stores currently in the connected database. The list MUST be sorted in ascending order using the algorithm defined by step 4 of section 11.8.5, The Abstract Relational Comparison Algorithm of the ECMAScript Language Specification [[!ECMA-262]]. Once the closePending flag is set on the connection, this function MUST return a snapshot of the list of names of the object stores taken at the time when the close method was called. Even if other connections are later used to change the set of object stores that exist in the database. In other words, the return value from this function stays constant for the lifetime of the IDBDatabase instance, except during a "versionchange" transaction if createObjectStore or deleteObjectStore is called on this IDBDatabase instance itself.
IDBObjectStore createObjectStore()

This method creates and returns a new object store with the given name in the connected database. If this function is called from outside a "versionchange" transaction callback, or if this function is called on a IDBDatabase object other than that transaction's connection, the implementation MUST throw a DOMException of type InvalidStateError.

If an objectStore with the same name already exists, the implementation MUST throw a DOMException of type ConstraintError. Otherwise, the implementation MUST create a new object store and return an IDBObjectStore object representing it.

This method synchronously modifies the IDBDatabase.objectStoreNames property. However it only changes the IDBDatabase.objectStoreNames property on the IDBDatabase instance on which it was called.

If the optionalParameters argument is specified and has a keyPath property which is not undefined or null, then set keyPath to the value of this property. If keyPath is an Array, then each item in the array is converted to a string. If keyPath is not an Array, it is converted to a string.

If keyPath is not a valid key path then a DOMException of type SyntaxError MUST be thrown. Otherwise set the created object store's key path to the value of keyPath.

If the optionalParameters parameter is specified, and autoIncrement is set to true, and the keyPath parameter is specified to the empty string, or specified to an Array, this function MUST throw a InvalidAccessError exception.

In some implementations it's possible for the implementation to run into problems after queuing up an operation to create the object store after the createObjectStore function has returned. For example in implementations where metadata about the newly created objectStore is inserted into the database asynchronously, or where the implementation might need to ask the user for permission for quota reasons. Such implementations MUST still create and return an IDBObjectStore object. Instead, once the implementation realizes that creating the objectStore has failed, it MUST abort the transaction using the steps for aborting a transaction using the appropriate error as error parameter. For example if creating the object store failed due to quota reasons, QuotaError MUST be used as error.

DOMString name
The name of a new object store
optional IDBObjectStoreParameters optionalParameters
The options object whose attributes are optional parameters to this function. keyPath specifies the key path of the new object store. If the attribute is null, no key path is specified and thus keys are out-of-line. autoIncrement specifies whether the object store created should have a key generator.
InvalidStateError
This method was not called from a "versionchange" transaction callback. Also occurs if a request is made on a source object that has been deleted or removed.
ConstraintError
An object store with the same name, compared in a case-sensitive manner, already exists in the connected database.
InvalidAccessError
If autoIncrement is set to true, and keyPath either is the empty string, or an Array containing the empty string.
void deleteObjectStore()

This method destroys the object store with the given name in the connected database. If this function is called from outside a "versionchange" transaction callback, or if this function is called on a IDBDatabase object other than that transactions connection, the implementation MUST throw a DOMException of type InvalidStateError.

This method synchronously modifies the IDBDatabase.objectStoreNames property. However it only changes the IDBDatabase.objectStoreNames property on the IDBDatabase instance on which it was called.

DOMString name
The name of an existing object store
InvalidStateError
This method was not called from a "versionchange" transaction callback. Also occurs if a request is made on a source object that has been deleted or removed.
NotFoundError
There is no object store with the given name, compared in a case-sensitive manner, in the connected database.
IDBTransaction transaction()

This method, when called MUST execute the steps for creating a transaction in an asychronous fashion. The storeNames and mode arguments are forwarded to the algorithm as-is. The callback argument is set to null. The timeout argument is set to infinite. The connection argument is set to the IDBDatabase that the transaction() method was called on.

The method returns an IDBTransaction object representing the transaction returned by the steps above.

If this method is called on IDBDatabase object for which a "versionchange" transaction is still running, a InvalidStateError exception MUST be thrown. I.e. if a "versionchange" transaction is started when a database is opened and this method is called on the IDBDatabase instance for that transaction before the transaction is committed, a InvalidStateError exception MUST be thrown. Likewise, if this method is called on a IDBDatabase instance where the closePending flag is set, a InvalidStateError exception MUST be thrown.

any storeNames
The names of object stores and indexes in the scope of the new transaction
optional DOMString mode
The mode for isolating access to data inside the given object stores. If this parameter is not provided, the default access mode is "readonly".
InvalidStateError
The close() method has been called on this IDBDatabase instance.
NotFoundError
One of the names provided in the storeNames argument doesn't exist in this database.
TypeError
The value for the mode parameter is invalid.
InvalidAccessError
The function was called with an empty list of store names
void close()
This method returns immediately and performs the steps for closing a database connection.
[TreatNonCallableAsNull] attribute Function? onabort
The event handler for the abort event.
[TreatNonCallableAsNull] attribute Function? onerror
The event handler for the error event.
[TreatNonCallableAsNull] attribute Function? onversionchange
The event handler for the versionchange event.

Object Store

Object store objects implement the following interface:
readonly attribute DOMString name
On getting, provide the name of this object store.
readonly attribute any keyPath
On getting, returns the key path of this object store. This will be either a DOMString, an Array of DOMStrings or null.
readonly attribute DOMStringList indexNames
On getting, provide a list of the names of indexes on objects in this object store. The list MUST be sorted in ascending order using the algorithm defined by step 4 of section 11.8.5, The Abstract Relational Comparison Algorithm of the ECMAScript Language Specification [[!ECMA-262]].
readonly attribute IDBTransaction transaction
On getting, returns the transaction this object store belongs to.
readonly attribute boolean autoIncrement;
On getting, provides the auto increment flag for this object store.
IDBRequest put()

This method throws a DOMException of type ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly". If any of the following conditions are true, this method throws a DOMException of type DataError:

Otherwise this method creates a structured clone of the value parameter. If the structured clone algorithm throws an exception, that exception is rethrown. Otherwise, run the steps for asynchronously executing a request and return the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for storing a record into an object store as operation, using this IDBObjectStore as store, the created clone as value, the key parameter as key, and with the no-overwrite flag flag set to false.

any value
The value to be stored in the record
optional any key
The key used to identify the record
TransactionInactiveError
The transaction this IDBObjectStore belongs to is not active.
ReadOnlyError
The mode of the associated transaction is "readonly".
DataError
The calculated key for the insertion was not a valid key.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
DataCloneError
The data being stored could not be cloned by the internal structured cloning algorithm.
IDBRequest add()

This method throws a DOMException of type ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly". If any of the following conditions are true, this method throws a DOMException of type DataError:

Otherwise this method creates a structured clone of the value parameter. If the structure clone algorithm throws an exception, that exception is rethrown. Otherwise, run the steps for asynchronously executing a request and return the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for storing a record into an object store as operation, using this IDBObjectStore as store, the created clone as value, the key parameter as key, and with the no-overwrite flag flag set to true.

To determine if a transaction has completed successfully, listen to the transaction’s complete event rather than the IDBObjectStore.add request’s success event, because the transaction may still fail after the success event fires.

any value
The value to be stored in the record
optional any key
The key used to identify the record
TransactionInactiveError
The transaction this IDBObjectStore belongs to is not active.
ReadOnlyError
The mode of the associated transaction is "readonly".
DataError
The calculated key for the insertion was not a valid key.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
DataCloneError
The data being stored could not be cloned by the internal structured cloning algorithm.
IDBRequest delete()

This method throws a ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly". If the key parameter is not a valid key or a key range this method throws a DOMException of type DataError.

Otherwise this method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for deleting records from an object store as operation, using this IDBObjectStore as store and the key parameter as key.

Unlike other methods which take keys or key ranges, this method does not allow null to be passed as key. This is to reduce the risk that a small bug would clear a whole object store.

any key
Key identifying the record to be deleted
TransactionInactiveError
The transaction this IDBObjectStore belongs to is not active.
ReadOnlyError
The mode of the transaction this IDBObjectStore belongs to is "readonly".
IDBRequest get()

If the key parameter is not a valid key or a key range, this method throws a DOMException of type DataError. Otherwise, this method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for retrieving a value from an object store as operation, using this IDBObjectStore as store and the key parameter as key.

This function produces the same result if a record with the given key doesn't exist as when a record exists, but has undefined as value. If you need to tell the two situations apart, you can use openCursor with the same key. This will return a cursor with undefined as value if a record exists, or no cursor if no such record exists.

any key
Key identifying the record to be retrieved. This can also be an IDBKeyRange in which case the function retreives the first existing value in that range.
TransactionInactiveError
The transaction this IDBObjectStore belongs to is not active.
DataError
The key parameter was not passed a valid value.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
IDBRequest clear()

This method throws a DOMException of type ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly".

Otherwise this method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for clearing an object store as operation, using this IDBObjectStore as store.

TransactionInactiveError
The transaction this IDBObjectStore belongs to is not active.
ReadOnlyError
The mode of the transaction this IDBObjectStore belongs to is "readonly".
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
IDBRequest openCursor()

If the range parameter is specified but is not a valid key or a key range, this method throws a DOMException of type DataError. Otherwise, this method creates a cursor. The cursor MUST implement the IDBCursorWithValue interface.

The newly created cursor MUST have an undefined position, a direction set to the value of the direction parameter, false as iterable flag value, and undefined key and value. The source of the cursor is the IDBObjectStore this function was called on.

If the range parameter is a key range then the cursor's range MUST be set to that range. Otherwise, if the range parameter is a valid key then the cursor's range is set to key range containing only that key value. If the range parameter is not specified, the cursor's key range is left as undefined.

This method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for iterating a cursor as operation, using the created cursor as cursor and with undefined as key.

optional any? range
The key range to use as the cursor's range
optional DOMString direction
The cursor's required direction
TransactionInactiveError
The transaction this IDBObjectStore belongs to is not active.
TypeError
The value for the direction parameter is invalid.
DataError
The range parameter was not passed key range or a valid key.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
IDBIndex createIndex()

This method creates and returns a new index with the given name and parameters in the connected database. If this function is called from outside a "versionchange" transaction callback, the implementation MUST throw an DOMException of type InvalidStateError exception. If an index with the same name already exists, the implementation MUST throw a DOMException of type ConstraintError. Otherwise, the implementation MUST create a new index and return an IDBIndex object representing it. The created index has its unique and multiEntry flags are set to the values of the unique and multiEntry properties in the optionalParameters argument.

If the keyPath argument is an Array, then each item in the array is converted to a DOMString. If keyPath is not an Array, it is converted to a DOMString.

If keyPath is not a valid key path then a DOMException of type SyntaxError MUST be thrown. Otherwise set the created object store's key path to the value of keyPath. If keyPath is an Array and the multiEntry property in the optionalParameters is true, then a DOMException of type InvalidAccessError MUST be thrown. Otherwise set the created index's key path to the value of keyPath.

The index that is requested to be created can contain constraints on the data allowed in the index's referenced object store, such as requiring uniqueness of the values referenced by the index's keyPath. If the referenced object store already contains data which violates these constraints, this MUST NOT cause the implementation of createIndex to throw an exception or affect what it returns. The implementation MUST still create and return an IDBIndex object. Instead the implementation must queue up an operation to abort the "versionchange" transaction which was used for the createIndex call.

This method will synchronously modify the IDBObjectStore.indexNames property.

In some implementations it's possible for the implementation to asynchronously run into problems creating the index after the createIndex function has returned. For example in implementations where metadata about the newly created index is queued up to be inserted into the database asynchronously, or where the implementation might need to ask the user for permission for quota reasons. Such implementations MUST still create and return an IDBIndex object. Instead, once the implementation realizes that creating the index has failed, it MUST abort the transaction using the steps for aborting a transaction using the appropriate error as error parameter. For example if creating the index failed due to quota reasons, QuotaError MUST be used as error and if the index can't be created due to unique constraints, ConstraintError MUST be used as error.

DOMString name
The name of a new index
any keyPath
The key path used by the new index.
optional IDBIndexParameters optionalParameters
The options object whose attributes are optional parameters to this function. unique specifies whether the index's unique flag is set. multiEntry specifies whether the index's multiEntry flag is set.
InvalidStateError
This method was not called from a "versionchange" transaction callback. Also occurs if a request is made on a source object that has been deleted or removed.
ConstraintError
An index with the same name, compared in a case-sensitive manner, already exists in the connected database.
IDBIndex index()
Returns an IDBIndex representing an index that is part of the object store. Every call to this function on the same IDBObjectStore instance and with the same name returns the same IDBIndex instance. However the retured IDBIndex instance is specific to this IDBObjectStore instance. If this function is called on a different IDBObjectStore instance, a different IDBIndex instance is returned. A result of this is that different IDBTransactions use different IDBIndex instances to represent the same index.
DOMString name
The name of an existing index
NotFoundError
There is no index with the given name, compared in a case-sensitive manner, in the connected database.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed, or if the transaction the object store belongs to has finished.
void deleteIndex()

This method destroys the index with the given name in the connected database. Note that this method must only be called from a "versionchange" transaction callback.

This method will synchronously modify the IDBObjectStore.indexNames property.

DOMString indexName
The name of an existing index
InvalidStateError
This method was not called from a "versionchange" transaction callback.
NotFoundError
There is no index with the given name, compared in a case-sensitive manner, in the connected database.
IDBRequest count()

If the optional key parameter is not a valid key or a key range, this method throws a DOMException of type DataError. This method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for iterating a cursor as operation, using the created cursor as cursor. If provided, use the key parameter as key, otherwise, use undefined as key. If the result of the algorithm is null return 0 (zero) as the result for the request. Otherwise, use the return cursor to determine the total number of objects that share the key or key range and return that value as the result for the request.

optional any key
Key identifying the record to be retrieved. This can also be an IDBKeyRange.
TransactionInactiveError
The transaction this IDBObjectStore belongs to is not active.
DataError
The key parameter is not a valid key or a key range.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.

Index

Index objects implement the following interface:

readonly attribute DOMString name
On getting, provide the name of this index.
readonly attribute IDBObjectStore objectStore
On getting, returns a reference to the IDBObjectStore instance for the referenced object store in this IDBIndex's transaction. This MUST return the same IDBObjectStore instance as was used to get a reference to this IDBIndex.
readonly attribute any keyPath
On getting, returns the key path of this index. This will be either a DOMString or an Array of DOMStrings.
readonly attribute boolean multiEntry
On getting, provide the multiEntry flag of this index.
readonly attribute boolean unique
On getting, provide the unique flag of this index.
IDBRequest openCursor()

If the range parameter is specified but is not a valid key or a key range, this method throws a DOMException of type DataError. Otherwise, this method creates a cursor. The cursor MUST implement the IDBCursorWithValue interface.

The newly created cursor MUST have an undefined position, a direction set to the value of the direction parameter, false as iterable flag value, and undefined key and value. The source of the cursor is the IDBIndex this function was called on.

If the range parameter is a key range then the cursor's range is set to that range. Otherwise, if the range parameter is a valid key then the cursor's range is set to key range containing only that key value. If the range parameter is not specified, the cursor's key range is left as undefined.

This method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBIndex as source and the steps for iterating a cursor as operation, using the created cursor as cursor and with undefined as key

optional any? range
The key range to use as the cursor's range
optional DOMString direction
The cursor's required direction
TransactionInactiveError
The transaction this IDBIndex belongs to is not active.
TypeError
The value for the direction parameter is invalid.
DataError
The range parameter was not passed key range or a valid key.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
IDBRequest openKeyCursor()

If the range parameter is specified but is not a valid key or a key range, this method throws a DOMException of type DataError. Otherwise, this method creates a cursor. The cursor MUST implement the IDBCursor interface, but MUST NOT implement the IDBCursorWithValue interface.

The newly created cursor MUST have an undefined position, a direction set to the value of the direction parameter, false as iterable flag value, and undefined key and value. The source of the cursor is the IDBIndex this function was called on.

If the range parameter is a key range then the cursor's range is set to that range. Otherwise, if the range parameter is a valid key then the cursor's range is set to key range containing only that key value. If the range parameter is not specified, the cursor's key range is left as undefined.

This method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for iterating a cursor as operation, using the created cursor as cursor and with undefined as key

optional any? range
The key range to use as the cursor's range
optional DOMString direction
The cursor's required direction
TransactionInactiveError
The transaction this IDBIndex belongs to is not active.
TypeError
The value for the direction parameter is invalid.
DataError
The range parameter was not passed key range or a valid key.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
IDBRequest get()

If the key parameter is not a valid key or a key range, this method throws a DOMException of type DataError. This method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for retrieving a referenced value from an index as operation, using this IDBIndex as index and the key parameter as key.

This function produces the same result if a record with the given key doesn't exist as when a record exists, but has undefined as value. If you need to tell the two situations apart, you can use openCursor with the same key. This will return a cursor with undefined as value if a record exists, or no cursor if no such record exists.

any key
Key identifying the record to be retrieved. This can also be an IDBKeyRange in which case the function retreives the first existing value in that range.
TransactionInactiveError
The transaction this IDBIndex belongs to is not active.
DataError
The key parameter was not passed a valid value.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
IDBRequest getKey()

Gets the primary key of the record from the referenced object store entry.

If the key parameter is not a valid key or a key range, this method throws a DOMException of type DataError. This method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBObjectStore as source and the steps for retrieving a value from an index as operation, using this IDBIndex as index and the key parameter as key.

any key
Key identifying the record to be retrieved. This can also be an IDBKeyRange in which case the function retreives the first existing value in that range.
TransactionInactiveError
The transaction this IDBIndex belongs to is not active.
DataError
The key parameter was not passed a valid value.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.
IDBRequest count()

If the optional key parameter is not a valid key or a key range, this method throws a DOMException of type DataError. This method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBIndex as source and the steps for iterating a cursor as operation, using the created cursor as cursor. If provided, use the key parameter as key, otherwise, use undefined as key. If the result of the algorithm is null return 0 (zero) as the result for the request. Otherwise, use the return cursor to determine the total number of objects that share the key or key range and return that value as the result for the request.

optional any key
Key identifying the record to be retrieved. This can also be an IDBKeyRange.
TransactionInactiveError
The transaction this IDBIndex belongs to is not active.
DataError
The key parameter is not a valid key or a key range.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed.

Cursor

Cursor objects implement the following interface:

readonly attribute object source
On getting, returns the IDBObjectStore or IDBIndex which this cursor is iterating. This function never returns null or throws an exception, even if the cursor is currently being iterated, has iterated past its end, or its transaction is not active.
readonly attribute DOMString direction
On getting, provide the traversal direction of the cursor.
readonly attribute any key
Returns the cursor's current key. Note that if this property returns an object (specifically an Array), it returns the same object instance every time it is inspected, until the cursor's key is changed. This means that if the object is modified, those modifications will be seen by anyone inspecting the value of the cursor. However modifying such an object does not modify the contents of the database.
readonly attribute any primaryKey
Returns the cursor's current effective key. Note that if this property returns an object (specifically an Array), it returns the same object instance every time it is inspected, until the cursor's effective key is changed. This means that if the object is modified, those modifications will be seen by anyone inspecting the value of the cursor. However modifying such an object does not modify the contents of the database.
IDBRequest update()

This method throws a DOMException of type ReadOnlyError if the transaction which this IDBCursor belongs to has its mode set to "readonly". If this cursor's got value flag is false or if this cursor was created using openKeyCursor. This method throws a DOMException of type InvalidStateError. If the effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key, this method throws a DOMException of type DataError.

Otherwise this method creates a structured clone of the value parameter. If the structured clone algorithm throws an exception, that exception is rethrown. Otherwise, run the steps for asynchronously executing a request and return the IDBRequest created by these steps. The steps are run with this IDBCursor as source and the steps for storing a record into an object store as operation, using this cursor's effective object store as store, the created clone as value, this cursor's effective key as key, and with the no-overwrite flag flag set to false.

A result of running the steps for storing a record into an object store is that if the record has been deleted since the cursor moved to it, a new record will be created.

any value
The new value to store at the current position.
TransactionInactiveError
The transaction this IDBCursor belongs to is not active.
ReadOnlyError
The mode of the transaction this IDBCursor belongs to is "readonly"
InvalidStateError
Thrown if cursor was created using openKeyCursor or if the cursor is currently being iterated or has iterated past the end.
DataError
The underlying object store uses in-line keys and the property in value at the object store's key path does not match the key in this cursor's position.
DataCloneError
The data being stored could not be cloned by the internal structured cloning algorithm.
void advance()

This method runs the steps for asynchronously executing a request. However, the steps are slightly modified such that instead of creating a new IDBRequest, it reuses the request originally created when this cursor was created. The done flag on the request is set to false before the request is returned. The steps are run with the cursor's source as source. The operation runs the steps for iterating a cursor count number of times with null as key and this cursor as cursor.

Before this method returns, unless an exception was thrown, it sets the got value flag on the cursor to false.

Calling this method more than once before new cursor data has been loaded is not allowed and results in a DOMException of type InvalidStateError being thrown. For example, calling advance() twice from the same onsuccess handler results in a DOMException of type InvalidStateError being thrown on the second call.

If the value for count is 0 (zero) or a negative number, this method MUST throw a JavaScript TypeError exception.

[EnforceRange] unsigned long count
The number of advances forward the cursor should make.
TypeError
The value passed into the count parameter was zero or a negative number.
TransactionInactiveError
The transaction this IDBCursor belongs to is not active.
InvalidStateError
The cursor is currently being iterated, or has iterated past its end.
void continue()

If this cursor's got value flag is false, this method throws a DOMException of type InvalidStateError. If the key parameter is specified and fulfills any of these conditions this method MUST throw a DOMException of type DataError:

Otherwise this method runs the steps for asynchronously executing a request. However, the steps are slightly modified such that instead of creating a new IDBRequest, it reuses the request originally created when this cursor was created. The done flag on the request is set to false before the request is returned. The steps are run with the cursor's source as source and the steps for iterating a cursor as operation, using this cursor as cursor and the key parameter as key.

Before this method returns, unless an exception was thrown, it sets the got value flag on the cursor to false.

Calling this method more than once before new cursor data has been loaded is not allowed and results in a DOMException of type InvalidStateError being thrown. For example, calling continue() twice from the same onsuccess handler results in a DOMException of type InvalidStateError being thrown on the second call.

optional any key
The next key to position this cursor at
TransactionInactiveError
The transaction this IDBCursor belongs to is not active.
InvalidStateError
The cursor is currently being iterated, or has iterated past its end.
DataError
The key parameter was specified but did not contain a valid key.
IDBRequest delete()

This method throws a DOMException of type ReadOnlyError if the transaction which this IDBCursor belongs to has its mode set to "readonly". If this cursor's got value flag is false, or if this cursor was created using openKeyCursor a DOMException of type InvalidStateError is thrown.

Otherwise this method runs the steps for asynchronously executing a request and returns the IDBRequest created by these steps. The steps are run with this IDBCursor as source and the steps for deleting records from an object store as operation, using this cursor's effective object store and effective key as store and key respectively.

TransactionInactiveError
The transaction this IDBCursor belongs to is not active.
ReadOnlyError
The mode of the transaction this IDBCursor belongs to is "readonly".
InvalidStateError
The cursor was created using openKeyCursor or the cursor is currently being iterated or has iterated past the end.
readonly attribute any value
Returns the cursor's current value. Note that if this property returns an object, it returns the same object instance every time it is inspected, until the cursor's value is changed. This means that if the object is modified, those modifications will be seen by anyone inspecting the value of the cursor. However modifying such an object does not modify the contents of the database.

Transaction

Transaction objects implement the following interface:

readonly attribute enum mode
On getting, provide the mode for isolating access to data inside the object stores that are in the scope of the transaction.
readonly attribute IDBDatabase db
The database connection of which this transaction is a part
readonly attribute DOMError error
If this transaction is not finished, is finished but was successfully committed, or was aborted due to a call to the abort function, this property returns null. If this transaction was aborted due to a failed request, this property returns the same DOMError as the request which caused this transaction to be aborted. If this transaction was aborted due to an error when committing the transaction, and not due to a failed request, this property returns a DOMError which contains the reason for the transaction failure (e.g. QuotaExceededError or UnknownError).
IDBObjectStore objectStore()
Returns an IDBObjectStore representing an object store that is part of the scope of this transaction. Every call to this function on the same IDBTransaction instance and with the same name returns the same IDBObjectStore instance. However the returned IDBObjectStore instance is specific to this IDBTransaction. If this function is called on a different IDBTransaction, a different IDBObjectStore instance is returned.
DOMString name
The requested object store
NotFoundError
If the requested object store is not in this transaction's scope.
InvalidStateError
Occurs if a request is made on a source object that has been deleted or removed, or if the transaction has finished.
void abort()
If this transaction is finished, throw a DOMException of type InvalidStateError. Otherwise this method sets the transaction's active flag to false and aborts the transaction by running the steps for aborting a transaction with the error parameter set to null.
InvalidStateError
If this transaction has already been committed or aborted.
[TreatNonCallableAsNull] attribute Function? onabort
The event handler for the abort event.
[TreatNonCallableAsNull] attribute Function? oncomplete
The event handler for the complete event.

To determine if a transaction has completed successfully, listen to the transaction’s complete event rather than the IDBObjectStore.add request’s success event, because the transaction may still fail after the success event fires.

[TreatNonCallableAsNull] attribute Function? onerror
The event handler for the error event.