public interface IDBFactory
The IDBFactory
interface of the IndexedDB API lets applications asynchronously access the indexed databases. The object that implements the interface is window.indexedDB
. You open—that is, create and access—and delete a database with the object and not directly with IDBFactory
.
This interface still has vendor prefixes, that is to say, you have to make calls with mozIndexedDB.open()
for Firefox and webkitIndexedDB.open()
for Chrome.
Modifier and Type | Method and Description |
---|---|
short |
cmp(Object first,
Object second)
Compares two values as keys to determine equality and ordering for IndexedDB operations, such as storing and iterating.
|
IDBVersionChangeRequest |
deleteDatabase(String name)
Request deleting a database.
|
IDBRequest |
getDatabaseNames() |
IDBRequest |
open(String name)
Warning: The description documents the old specification.
|
short cmp(Object first, Object second)
Compares two values as keys to determine equality and ordering for IndexedDB operations, such as storing and iterating. Do not use this method for comparing arbitrary JavaScript values, because many JavaScript values are either not valid IndexedDB keys (booleans and objects, for example) or are treated as equivalent IndexedDB keys (for example, since IndexedDB ignores arrays with non-numeric properties and treats them as empty arrays, so any non-numeric array are treated as equivalent).
This throws an exception if either of the values is not a valid key.
Returned value | Description |
---|---|
-1 | 1st key < 2nd |
0 | 1st key = 2nd |
1 | 1st key > 2nd |
This method can raise an IDBDatabaseException with the following code:
Attribute | Description |
---|---|
NON_TRANSIENT_ERR | One of the supplied keys was not a valid key. |
IDBVersionChangeRequest deleteDatabase(String name)
Request deleting a database. The method returns an IDBRequest object immediately, and performs the deletion operation asynchronously.
The deletion operation (performed in a different thread) consists of the following steps:
version
set to null
.blocked
event at the request object returned by the deleteDatabase
method, using IDBVersionChangeEvent with version
set to null
.If the database is successfully deleted, then an IDBSuccessEvent is fired on the request object returned from this method, with its result
set to null
.
If an error occurs while the database is being deleted, then an error event is fired on the request object that is returned from this method, with its code
and message
set to appropriate values.
Tip: If the browser you are using hasn't implemented this yet, you can delete the object stores one by one, thus effectively removing the database.
IDBRequest
IDBOpenRequest
.IDBRequest getDatabaseNames()
IDBRequest open(String name)
Request opening a connection to a database. The method returns an IDBRequest object immediately, and performs the opening operation asynchronously.
The opening operation—which is performed in a separate thread—consists of the following steps:
myAwesomeDatabase
already exists: VERSION_CHANGE
transactions have finished.If the operation is successful, an IDBSuccessEvent is fired on the request object that is returned from this method, with its result attribute set to the new IDBDatabase object for the connection.
If an error occurs while the database connection is being opened, then an error event is fired on the request object returned from this method, with its code
and message
set to appropriate values.
IDBRequest
IDBOpenRequest
.Copyright © 2016. All rights reserved.