< apis(Redirected from apis/indexedDB)
Jump to: navigation, search

IndexedDB reference

This article is Almost Ready.

W3C Working Draft


IndexedDB is a client side storage API that persists data in a user's browser. It is a transactional, non-relational storage mechanism that saves key-value pairs in Object Stores and allows searching data using indexes.

API Name Summary
IDBCursor Iterates over object stores and indices.
IDBCursorWithValue Returns the IDBCursor's value.
IDBDatabase Represents a database connection for the purpose of conducting a transaction.
IDBDatabaseException Not supported.
IDBFactory The object type for the indexedDB property, which provides access to the IndexedDB features supported by the browser and/or device.
IDBIndex A metadata index to a referenced object store.
IDBKeyRange A range of keys defined for an object store or index.
IDBObjectStore Represents an object store in a database.
IDBOpenDBRequest Provides access to the result of a request to open a database.
IDBRequest Provides access to the result of a request on the database.
IDBTransaction Provides for the scope and type of access to a database, and represents a transaction on the database.
IDBVersionChangeEvent The IDBVersionChangeEvent object represents the event object passed to the upgradeneeded event, which fires when a database is opened using a higher version number.
IDBVersionChangeRequest Deprecated. Previously used to change the version of the database.
indexedDB Implements the IDBFactory object's open method, thereby providing the way to open (create or access) a database.


indexedDB = window.indexedDB;


The IndexedDB specification supports an Asynchronous API on the window object and a Synchronous API for Webworkers.



Each origin has a set of associated databases. Database comprise of Object Stores that store data

Object Store

Object Stores have list of records which hold data as key-value pairs. Every Object Store belongs to a database.


Every record in an object store is stored as key-value pairs. Keys are indexed for easy retrieval of data. A valid key can be an Array, Date, DOMString or float. Keys can either be generated automatically using a key generator, or specified during data insertion. Keys can also be derived from values using a key path attribute specified for an Object Store


Every record has a value that contains the data for a record. A value must be supported by the Structured Cloning Algorithm.


An index allows looking up records in an object store using properties of the values in the object stores records. An index is a specialized persistent key-value storage and has a referenced object store. The index has a list of records which hold the data stored in the index. The records in an index are automatically populated whenever records in the referenced object store are inserted, updated or deleted. There can be several indexes referencing the same object store, in which changes to the object store cause all such indexes to get updated.


A cursor is a transient construct to iterate over the records in a database. Cursors can be used on Object Stores or Indexes


All database read and write operations occur in transactions. Transactions can be read or read_write. A version_change transaction is a special transaction that allows adding or deleting Object Stores or Indexes.


Each reading and writing operation on a database is done using a request. The result of a request is usually available in success or error events raised on the request.


The IndexedDB storage follows the same-origin policy.

Storage Limits

See also

External resources


  • IDBWrapper Ease the use of indexedDB and abstract away the differences between the existing implementations in Chrome, Firefox and IE10 (yes, it works in all three). Show how IDB works. The code is split up into short methods, so that it's easy to see what happens in what method.[1]

  • YDN-DB Javascript database module for Indexeddb, Web SQL and localStorage storage mechanisms supporting version migration, advanced query, SQL and transaction. API Documentations