Important: The synchronous version of the IndexedDB API was originally intended for use only with Web Workers, and was eventually removed from the spec because its need was questionable. It may however be reintroduced in the future if there is enough demand from web developers.
The IDBObjectStoreSync
interface of the IndexedDB API provides synchronous access to an object store of a database.
any add (in any value, in optional any key) raises (IDBDatabaseException); |
IDBIndexSync createIndex (in DOMString name, in DOMString storeName, in DOMString keypath, in optional boolean unique);
|
any get (in any key) raises (IDBDatabaseException); |
IDBCursorSync openCursor (in optional IDBKeyRange range, in optional unsigned short direction) raises (IDBDatabaseException); |
IDBIndexSync openIndex (in DOMString name) raises (IDBDatabaseException); |
any put (in any value, in optional any key) raises (IDBDatabaseException); |
void remove (in any key) raises (IDBDatabaseException); |
void removeIndex (in DOMString indexName) raises (IDBDatabaseException); |
Attribute | Type | Description |
---|---|---|
indexNames | readonly DOMStringList | A list of the names of the indexes on this object store. |
keyPath | readonly DOMString | The key path of this object store. If this attribute is set to null, then the application must provide a key for each modification operation. |
mode | readonly unsigned short | The mode for isolating access to the data in this object store. For possible values, see Constants. |
name | readonly DOMString | The name of this object store. |
Constant | Value | Description |
---|---|---|
READ_ONLY | 1 | Modification operations are not allowed on this object store. |
READ_WRITE | 0 | Modification operations are allowed on this object store. |
SNAPSHOT_READ | 2 | Any read operations must access a snapshot view of the data, which cannot change once it is created. |
Stores the given value into this object store, optionally with the specified key. If a record already exists with the given key, an exception is raised.
any add( in any value, in optional any key ) raises (IDBDatabaseException);
This method can raise a IDBDatabaseException with the following codes:
any
CONSTRAINT_ERR
DATA_ERR
SERIAL_ERR
Creates and returns a new index with the given name in the connected database.
IDBIndexSync createIndex ( in DOMString name, in DOMString keypath, in optional boolean unique );
IDBIndexSync
Retrieves and returns the value from this object store for the record that corresponds to the given key.
any get ( in any key ) raises (IDBDatabaseException);
any
This method can raise a IDBDatabaseException with the following codes:
SERIAL_ERR
NOT_FOUND_ERR
Creates a cursor over the records of this object store. The range of the new cursor matches the specified key range; if the key range is not specified or is null, then the range includes all the records.
CursorSync openCursor ( in optional KeyRange range, in optional unsigned short direction ) raises (DatabaseException);
IDBIndexSync
This method can raise a DatabaseException with the following code:
NOT_FOUND_ERR
Opens the index with the given name, using the mode of the current transaction.
IDBIndexSync openIndex ( in DOMString name ) raises (IDBDatabaseException);
IDBIndexSync
This method can raise an IDBDatabaseException with the following code:
NOT_FOUND_ERR
Stores the given value in this object store and returns the key for the stored record. If a record already exists with the given key, it is overwritten.
any put ( in any value, in optional any key ) raises (IDBDatabaseException);
any
This method can raise an IDBDatabaseException with the following codes:
CONSTRAINT_ERR
DATA_ERR
SERIAL_ERR
Removes from this object store any records that correspond to the given key.
void remove ( in any key ) raises (IDBDatabaseException);
void
This method can raise a IDBDatabaseException with the following code:
NOT_FOUND_ERR
Destroys an index with the given name.
void removeIndex ( in DOMString indexName ) raises (IDBDatabaseException);
This method can raise an IDBDatabaseException with the following code:
NOT_FOUND_ERR
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStoreSync