{{ Fx_minversion_header("4") }}{{ draft() }}
The IDBIndexSync
interface of the IndexedDB API provides synchronous access to an index in a database.
Method overview
any add (in any value, in optional any key) raises (IDBDatabaseException); |
any get (in any key) raises (IDBDatabaseException); |
any getObject (in any key) raises (IDBDatabaseException); |
void openCursor (in optional IDBKeyRange range, in optional unsigned short direction) raises (IDBDatabaseException); |
void openObjectCursor (in optional IDBKeyRange range, in optional unsigned short direction) raises (IDBDatabaseException); |
any put (in any value, in optional any key) raises (IDBDatabaseException); |
void remove (in any key) raises (IDBDatabaseException); |
Attributes
Attribute | Type | Description |
---|---|---|
keyPath | readonly DOMString | The key path of this index. If this attribute is null, this index is not auto-populated. |
name | readonly DOMString | The name of this index. |
storeName | readonly DOMString | This index's referenced object store. |
unique | readonly boolean | If true, a key can have only one value within the index; if false, a key can have duplicate values. |
Methods
add()
Stores the given value into this index, 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);
Parameters
- value
- The value to store into the index.
- key
- A key to use for identifying the record.
any
- The key for the stored record.
CONSTRAINT_ERR
- If a record exists in this index with a key corresponding to the key parameter or the index is auto-populated, or if no record exists with a key corresponding to the value parameter in the index's referenced object store.
Returns
Exceptions
This method can raise a IDBDatabaseException with the following code:
get()
Retrieves the value from this index for the record that corresponds to the given key.
any get ( in any key ) raises (IDBDatabaseException);
Parameters
- key
- The key that identifies the record to be retrieved.
Returns
any
- The retrieved value from the index.
Exceptions
This method can raise an IDBDatabaseException with the following code:
NOT_FOUND_ERR
- If no record exists in this index for the given key.
getObject()
Retrieves and returns the value from this index's referenced object store that corresponds to the given key.
any getObject ( in any key ) raises (IDBDatabaseException);
Parameters
- key
- The key that identifies the record to be retrieved.
Returns
any
- The retrieved value from the referenced object store.
Exceptions
This method can raise a IDBDatabaseException with the following code:
NOT_FOUND_ERR
- If no record exists in this index for the given key.
openCursor()
Creates a cursor over the records of this index. 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.
void openCursor ( in optional IDBKeyRange range, in optional unsigned short direction ) raises (IDBDatabaseException);
Parameters
- range
- The key range to use as the cursor's range.
- direction
- The cursor's required direction.
Returns
void
Exceptions
This method can raise an IDBDatabaseException with the following code:
NOT_FOUND_ERR
- If no records exist in this index for the requested key range.
openObjectCursor()
Creates a cursor over the records of this index's referenced object store, as arranged by this index. 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.
void openObjectCursor ( in optional IDBKeyRange range, in optional unsigned short direction ) raises (IDBDatabaseException);
Parameters
- range
- The key range to use as the cursor's range.
- direction
- The cursor's required direction.
Returns
void
Exceptions
This method can raise an IDBDatabaseException with the following code:
NOT_FOUND_ERR
- If no records exist in this index for the requested key range.
put()
Stores the given value in this index and returns the key for the stored record. If a record already exists with the given key, the record is overwritten.
any put ( in any value, in optional any key) raises (IDBDatabaseException);
Parameters
- value
- The value to be stored in the record.
- key
- The key to be used to identify the record.
Returns
- any
- The key for the stored record.
remove()
Removes from this index any records that correspond to the given key.
void remove ( in any key ) raises (IDBDatabaseException);
Parameters
- key
- Key of the records to be removed.
Exceptions
This method can raise a DatabaseException with the following code:
NOT_FOUND_ERR
- If a record does not exist in this index with the given key.