Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 415199 of IDBIndexSync

  • Revision slug: Web/API/IDBIndexSync
  • Revision title: IDBIndexSync
  • Revision id: 415199
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 8 words removedIndexedDB/IDBIndexSync Web/API/IDBIndexSync

Revision Content

{{ 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.
Returns
any
The key for the stored record.
Exceptions

This method can raise a IDBDatabaseException with the following code:

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.

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.

Revision Source

<p>{{ draft() }}</p>
<p>The <code>IDBIndexSync</code> interface of the <a href="/en/IndexedDB" title="en/IndexedDB">IndexedDB API</a> provides synchronous access to an <a href="/en/IndexedDB#gloss_index" title="en/IndexedDB#gloss index">index</a> in a database.</p>
<h2 id="Method_overview">Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>any <a href="#add" title="#add">add</a> (in any value, in optional any key) raises (<a href="/IDBDatabaseException" title="IDBDatabaseException">IDBDatabaseException</a>);</code></td> </tr> <tr> <td><code>any <a href="#get" title="#get">get</a> (in any key) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/IDBDatabaseException">IDBDatabaseException</a>);<br> </code></td> </tr> <tr> <td><code>any <a href="#getObject" title="#getObject">getObject</a> (in any key) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/IDBDatabaseException">IDBDatabaseException</a>);<br> </code></td> </tr> <tr> <td><code>void <a href="#openCursor" title="#openCursor">openCursor</a> (in optional <a href="/en/IndexedDB/IDBKeyRange" title="en/IndexedDB/IDBKeyRange">IDBKeyRange</a> range, in optional unsigned short direction) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/IDBDatabaseException">IDBDatabaseException</a>);<br> </code></td> </tr> <tr> <td><code>void <a href="#openObjectCursor" title="#openObjectCursor">openObjectCursor</a> (in optional <a href="/en/IndexedDB/IDBKeyRange" title="en/IndexedDB/IDBKeyRange">IDBKeyRange</a> range, in optional unsigned short direction) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/IDBDatabaseException">IDBDatabaseException</a>);<br> </code></td> </tr> <tr> <td><code>any <a href="#put" title="#put">put</a> (in any value, in optional any key) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/IDBDatabaseException">IDBDatabaseException</a>);<br> </code></td> </tr> <tr> <td><code>void <a href="#remove" title="#remove">remove</a> (in any key) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/IDBDatabaseException">IDBDatabaseException</a>);</code></td> </tr> </tbody>
</table>
<h2 id="Attributes">Attributes</h2>
<table class="standard-table"> <thead> <tr> <th scope="col">Attribute</th> <th scope="col">Type</th> <th scope="col">Description</th> </tr> </thead> <tbody> <tr> <td><code><a name="attr_keyPath">keyPath</a><br> </code></td> <td><code>readonly DOMString<br> </code></td> <td>The <a href="/en/IndexedDB#gloss_key_path" title="en/IndexedDB#gloss key path">key path</a> of this index. If this attribute is null, this index is not <a href="/en/IndexedDB#gloss_auto-populated" title="en/IndexedDB#gloss auto-populated">auto-populated</a>.</td> </tr> <tr> <td><code><a name="attr_name">name</a><br> </code></td> <td><code>readonly DOMString<br> </code></td> <td>The name of this index.</td> </tr> <tr> <td><code><a name="attr_storeName">storeName</a><br> </code></td> <td><code>readonly DOMString<br> </code></td> <td>This index's <a href="/en/IndexedDB#gloss_referenced_object_store" title="en/IndexedDB#gloss referenced object store">referenced object store</a>.</td> </tr> <tr> <td><code><a name="attr_unique">unique</a><br> </code></td> <td><code>readonly boolean<br> </code></td> <td>If true, a key can have only one value within the index; if false, a key can have duplicate values.</td> </tr> </tbody>
</table>
<h2 id="Methods">Methods</h2>
<h3 id="add" name="add">add()</h3>
<p>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.</p>
<pre>any add( 
  in any value,
  in optional any key
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>value</dt> <dd>The value to store into the index.</dd> <dt>key</dt> <dd>A key to use for identifying the record.</dd> <h5 id="Returns">Returns</h5> <dt><code>any</code></dt> <dd>The key for the stored record.</dd> <h5 id="Exceptions">Exceptions</h5> <p>This method can raise a IDBDatabaseException with the following code:</p> <dt><a href="/en/IndexedDB/IDBDatabaseException#CONSTRAINT_ERR" title="en/IndexedDB/DatabaseException#CONSTRAINT ERR"><code>CONSTRAINT_ERR</code></a></dt> <dd>If a record exists in this index with a key corresponding to the <em>key</em> parameter or the index is auto-populated, or if no record exists with a key corresponding to the <em>value</em> parameter in the index's referenced object store.</dd>
</dl>
<h3 id="get()">get()</h3>
<p>Retrieves the value from this index for the record that corresponds to the given key.</p>
<pre>any get (
  in any key
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>key</dt> <dd>The key that identifies the record to be retrieved.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<dl> <dt><code>any</code></dt> <dd>The retrieved value from the index.</dd>
</dl>
<h5 id="Exceptions">Exceptions</h5>
<p>This method can raise an IDBDatabaseException with the following code:</p>
<dl> <dt><code><a href="/en/IndexedDB/IDBDatabaseException#NOT_FOUND_ERR" title="en/IndexedDB/DatabaseException#NOT FOUND ERR">NOT_FOUND_ERR</a></code></dt> <dd>If no record exists in this index for the given key.</dd>
</dl>
<h3 id="getObject" name="getObject">getObject()</h3>
<p>Retrieves and returns the value from this index's referenced object store that corresponds to the given key.</p>
<pre>any getObject (
  in any key
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>key</dt> <dd>The key that identifies the record to be retrieved.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<dl> <dt><code>any</code></dt> <dd>The retrieved value from the referenced object store.</dd>
</dl>
<h5 id="Exceptions">Exceptions</h5>
<p>This method can raise a IDBDatabaseException with the following code:</p>
<dl> <dt><code><a href="/en/IndexedDB/IDBDatabaseException#NOT_FOUND_ERR" title="en/IndexedDB/DatabaseException#NOT FOUND ERR">NOT_FOUND_ERR</a></code></dt> <dd>If no record exists in this index for the given key.</dd>
</dl>
<h3 id="openCursor" name="openCursor">openCursor()</h3>
<p>Creates a <a href="/en/IndexedDB#gloss_cursor" title="en/IndexedDB#gloss cursor">cursor</a> over the records of this index. The range of the new cursor matches the specified <a href="/en/IndexedDB#gloss_key_range" title="en/IndexedDB#gloss key range">key range</a>; if the key range is not specified or is null, then the range includes all the records.</p>
<pre>void openCursor (
  in optional IDBKeyRange range, 
  in optional unsigned short direction
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>range</dt> <dd>The key range to use as the cursor's range.</dd> <dt>direction</dt> <dd>The cursor's required direction.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<p><code>void</code></p>
<h5 id="Exceptions">Exceptions</h5>
<p>This method can raise an IDBDatabaseException with the following code:</p>
<dl> <dt><code><a href="/en/IndexedDB/IDBDatabaseException#NOT_FOUND_ERR" title="en/IndexedDB/DatabaseException#NOT FOUND ERR">NOT_FOUND_ERR</a></code></dt> <dd>If no records exist in this index for the requested key range.</dd>
</dl>
<h3 id="openObjectCursor" name="openObjectCursor">openObjectCursor()</h3>
<p>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.</p>
<pre>void openObjectCursor (
  in optional IDBKeyRange range, 
  in optional unsigned short direction
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>range</dt> <dd>The key range to use as the cursor's range.</dd> <dt>direction</dt> <dd>The cursor's required direction.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<p><code>void</code></p>
<h5 id="Exceptions">Exceptions</h5>
<p>This method can raise an IDBDatabaseException with the following code:</p>
<dl> <dt><code><a href="/en/IndexedDB/IDBDatabaseException#NOT_FOUND_ERR" title="en/IndexedDB/DatabaseException#NOT FOUND ERR">NOT_FOUND_ERR</a></code></dt> <dd>If no records exist in this index for the requested key range.</dd>
</dl>
<h3 id="put" name="put">put()</h3>
<p>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.</p>
<pre>any put (
  in any value, 
  in optional any key) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>value</dt> <dd>The value to be stored in the record.</dd> <dt>key</dt> <dd>The key to be used to identify the record.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<dl> <dt>any</dt> <dd>The key for the stored record.</dd>
</dl>
<h3 id="remove" name="remove">remove()</h3>
<p>Removes from this index any records that correspond to the given key.</p>
<pre>void remove (
  in any key
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>key</dt> <dd>Key of the records to be removed.</dd>
</dl>
<h5 id="Exceptions">Exceptions</h5>
<p>This method can raise a DatabaseException with the following code:</p>
<dl> <dt><code><a href="/en/IndexedDB/IDBDatabaseException#NOT_FOUND_ERR" title="en/IndexedDB/DatabaseException#NOT FOUND ERR">NOT_FOUND_ERR</a></code></dt> <dd>If a record does not exist in this index with the given key.</dd>
</dl>
Revert to this revision