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 76896 of IDBDatabaseSync

  • Revision slug: IndexedDB/IDBDatabaseSync
  • Revision title: IDBDatabaseSync
  • Revision id: 76896
  • Created:
  • Creator: jswisher
  • Is current revision? No
  • Comment 8 words removed

Revision Content

{{ draft() }}

The DatabaseSync interface in the IndexedDB API represents a synchronous connection to a database.

Method overview

IDBObjectStoreSync createObjectStore (in DOMString name, in DOMString keypath, in optional boolean autoIncrement) raises (IDBDatabaseException);
IDBObjectStoreSync openObjectStore (in DOMString name, in optional unsigned short mode) raises (IDBDatabaseException);
void removeObjectStore (in DOMString storeName) raises (IDBDatabaseException);
void setVersion (in DOMString version);
IDBTransactionSync transaction (in optional DOMStringList storeNames, in optional unsigned int timeout) raises (IDBDatabaseException);

Attributes

Attribute Type Description
description readonly DOMString The human-readable description of the connected database.
name readonly DOMString The name of the connected database.
objectStores readonly DOMStringList The names of the object stores that exist in the connected database.
version readonly DOMString The version of the connected database. Has the null value when the database is first created.

Methods

createObjectStore()

Creates and returns a new object store with the given name in the connected database.

 IDBObjectStoreSync createObjectStore(   
  in DOMString name,   
  in DOMString keypath,   
  in optional boolean autoIncrement 
) raises  (IDBDatabaseException);
Parameters
name
The name of a new object store.
keypath
The key path used by the new object store. If a null path is specified, then the object store does not have a key path, and uses out-of-line keys.
autoIncrement
If true, the object store uses a key generator; if false, it does not use one.
Returns
IDBObjectStoreSync
An object to access the newly created object store.
Exceptions

This method can raise an IDBDatabaseException with the following code:

CONSTRAINT_ERR
If an object store with the same name (based on case-sensitive comparison) already exists in the connected database.

openObjectStore()

Opens the object store with the given name in the connected database using the specified mode.

IDBObjectStoreSync openObjectStore (
  in DOMString name, 
  in optional unsigned short mode
) raises (IDBDatabaseException);
Parameters
name
The name of the object store to open.
mode
The mode that is used to access the object store.
Returns
IDBObjectStoreSync
An object to access the opened object store.
Exceptions

This method can raise an IDBDatabaseException with the following code:

NOT_FOUND_ERR
If an object store with the given name (based on case-sensitive comparison) already exists in the connected database.

removeObjectStore()

Destroys an object store with the given name, as well as all indexes that reference that object store.

void removeObjectStore (
  in DOMString storeName
) raises (IDBDatabaseException);
Parameters
storeName
The name of an existing object store to remove.
Returns

void

Exceptions

This method can raise an IDBDatabaseException with the following code:

NOT_FOUND_ERR
If the object store with the given name (based on case-sensitive comparison) does not exist in the connected database.

setVersion()

Sets the version of the connected database.

void setVersion (
  in DOMString version
);
Parameters
version
The version to store in the database.
Returns

void

transaction()

Creates and returns a transaction, acquiring locks on the given database objects, within the specified timeout duration, if possible.

IDBTransactionSync transaction (
  in optional DOMStringList storeNames,
  in optional unsigned int timeout
) raises (IDBDatabaseException);
Parameters
storeNames
The names of object stores and indexes in the scope of the new transaction.
timeout
The interval that this operation is allowed to take to acquire locks on all the objects stores and indexes identified in storeNames.
Returns
IDBTransactionSync
An object to access the newly created transaction.
Exceptions

This method can raise an IDBDatabaseException with the following code:

TIMEOUT_ERR
If reserving all the database objects identified in storeNames takes longer than the timeout interval.

Revision Source

<p>{{ draft() }}</p>
<p>The <code>DatabaseSync</code> interface in the <a href="/en/IndexedDB" title="en/IndexedDB">IndexedDB API</a> represents a synchronous <a href="/en/IndexedDB#gloss_database_connection" title="en/IndexedDB#gloss database connection">connection to a database</a>.</p>
<h2 id="Method_overview">Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code><a href="/en/IndexedDB/IDBObjectStoreSync" title="en/IndexedDB/ObjectStoreSync">IDBObjectStoreSync</a> <a href="#createObjectStore" title="#createObjectStore">createObjectStore</a> (in DOMString <code>name</code>, in DOMString keypath, in optional boolean autoIncrement) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/DatabaseException">IDBDatabaseException</a>); </code></td> </tr> <tr> <td><code><a href="/en/IndexedDB/IDBObjectStoreSync" title="en/IndexedDB/ObjectStoreSync">IDBObjectStoreSync</a> <a href="#openObjectStore" title="#openObjectStore">openObjectStore</a> (in DOMString name, in optional unsigned short mode) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/DatabaseException">IDBDatabaseException</a>);</code></td> </tr> <tr> <td><code>void <a href="#removeObjectStore" title="#removeObjectStore">removeObjectStore</a> (in DOMString storeName) raises (<a href="/en/IndexedDB/IDBDatabaseException" title="en/IndexedDB/IDBDatabaseException">IDBDatabaseException</a>);</code></td> </tr> <tr> <td><code>void <a href="#setVersion" title="#setVersion">setVersion</a> (in DOMString version);</code></td> </tr> <tr> <td><code><a href="/en/IndexedDB/IDBTransactionSync" title="en/IndexedDB/TransactionSync">IDBTransactionSync</a> <a href="#transaction" title="#transaction">transaction</a> (in optional DOMStringList storeNames, in optional unsigned int timeout) 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_description">description</a></code></td> <td><code> readonly DOMString </code></td> <td>The human-readable description of the connected database.</td> </tr> <tr> <td><a name="attr_name"><code></code></a><code><a>name</a> </code></td> <td><code> readonly DOMString </code></td> <td>The name of the connected database.</td> </tr> <tr> <td><a name="attr_objectStores"><code></code></a><code><a>objectStores</a> </code></td> <td><code> readonly DOMStringList </code></td> <td>The names of the object stores that exist in the connected database.</td> </tr> <tr> <td><a name="attr_version"><code></code></a><code><a>version</a> </code></td> <td><code> readonly DOMString</code></td> <td>The version of the connected database. Has the null value when the database is first created.</td> </tr> </tbody>
</table>
<h2 id="Methods">Methods</h2>
<h3 id="createObjectStore" name="createObjectStore">createObjectStore()</h3>
<p>Creates and returns a new object store with the given name in the connected database.</p>
<pre class="eval"> IDBObjectStoreSync createObjectStore(   
  in DOMString name,   
  in DOMString keypath,   
  in optional boolean autoIncrement 
) raises  (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>name</dt> <dd>The name of a new object store.</dd> <dt>keypath</dt> <dd>The <a href="/en/IndexedDB#gloss_key_path" title="en/IndexedDB#gloss key path">key path</a> used by the new object store. If a null path is specified, then the object store does not have a key path, and uses out-of-line keys.</dd> <dt>autoIncrement</dt> <dd>If true, the object store uses a <a href="/en/IndexedDB#gloss_key_generator" title="en/IndexedDB#gloss key generator">key generator</a>; if false, it does not use one.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<dl> <dt><a href="/en/IndexedDB/IDBObjectStoreSync" title="en/IndexedDB/ObjectStoreSync"><code>IDBObjectStoreSync</code></a></dt> <dd>An object to access the newly created object store.</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#CONSTRAINT_ERR" title="en/IndexedDB/DatabaseException#CONSTRAINT ERR">CONSTRAINT_ERR</a></code></dt> <dd>If an object store with the same name (based on case-sensitive comparison) already exists in the connected database.</dd>
</dl>
<h3 id="openObjectStore" name="openObjectStore">openObjectStore()</h3>
<p>Opens the object store with the given name in the connected database using the specified mode.</p>
<pre>IDBObjectStoreSync openObjectStore (
  in DOMString name, 
  in optional unsigned short mode
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>name</dt> <dd>The name of the object store to open.</dd> <dt>mode</dt> <dd>The mode that is used to access the object store.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<dl> <dt><a href="/en/IndexedDB/IDBObjectStoreSync" title="en/IndexedDB/ObjectStoreSync"><code>IDBObjectStoreSync</code></a></dt> <dd>An object to access the opened object store.</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 an object store with the given name (based on case-sensitive comparison) already exists in the connected database.</dd>
</dl>
<h3 id="removeObjectStore" name="removeObjectStore">removeObjectStore()</h3>
<p>Destroys an object store with the given name, as well as all indexes that reference that object store.</p>
<pre>void removeObjectStore (
  in DOMString storeName
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>storeName</dt> <dd>The name of an existing object store to remove.</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>
</dl>
<dl> <dd>If the object store with the given name (based on case-sensitive comparison) does not exist in the connected database.</dd>
</dl>
<h3 id="setVersion()" name="">setVersion()</h3>
<p>Sets the version of the connected database.</p>
<pre>void setVersion (
  in DOMString version
);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>version</dt> <dd>The version to store in the database.</dd> <h5 id="Returns">Returns</h5> <p><code>void</code></p>
</dl>
<h3 id="transaction" name="transaction">transaction()</h3>
<p>Creates and returns a transaction, acquiring locks on the given database objects, within the specified timeout duration, if possible.</p>
<pre>IDBTransactionSync transaction (
  in optional DOMStringList storeNames,
  in optional unsigned int timeout
) raises (IDBDatabaseException);
</pre>
<h5 id="Parameters">Parameters</h5>
<dl> <dt>storeNames</dt> <dd>The names of object stores and indexes in the scope of the new transaction.</dd> <dt>timeout</dt> <dd>The interval that this operation is allowed to take to acquire locks on all the objects stores and indexes identified in <code>storeNames</code>.</dd>
</dl>
<h5 id="Returns">Returns</h5>
<dl> <dt><code><a href="/en/IndexedDB/IDBTransactionSync" title="en/IndexedDB/TransactionSync">IDBTransactionSync</a></code></dt> <dd>An object to access the newly created transaction.</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#TIMEOUT_ERR" title="en/IndexedDB/DatabaseException#TIMEOUT ERR">TIMEOUT_ERR</a></code></dt> <dd>If reserving all the database objects identified in <code>storeNames</code> takes longer than the <code>timeout</code> interval.</dd>
</dl>
Revert to this revision