The IDBEnvironment
interface of the IndexedDB API contains the indexedDB
property, which provides access to IndexedDB functionality. It is the top level IndexedDB interface implemented by the window
and Worker
objects.
Note: This feature is available in Web Workers.
PropertiesEdit
IDBEnvironment.indexedDB
Read only- Provides a mechanism for applications to asynchronously access capabilities of indexed databases; contains an
IDBFactory
object.
ExampleEdit
The following code creates a request for a database to be opened asychronously, after which the database is opened when the request's onsuccess
handler is fired:
var db;
function openDB() {
var DBOpenRequest = window.indexedDB.open("toDoList");
DBOpenRequest.onsuccess = function(e) {
db = DBOpenRequest.result;
};
}
SpecificationsEdit
Specification | Status | Comment |
---|---|---|
Indexed Database API The definition of 'IDBEnvironment' in that specification. |
Recommendation |
Browser compatibilityEdit
Be careful in Chrome as it still implements the old specification along with the new one. Similarly it still has the prefixed webkitIndexedDB
property even if the unprefixed indexedDB
is present.
See alsoEdit
- Using IndexedDB
- Starting transactions:
IDBDatabase
- Using transactions:
IDBTransaction
- Setting a range of keys:
IDBKeyRange
- Retrieving and making changes to your data:
IDBObjectStore
- Using cursors:
IDBCursor
- Reference example: To-do Notifications (view example live.)