The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.
Indexed Database API
This article is Ready to Use.
W3C Proposed Recommendation
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.
|IDBCursorWithValue||Returns the IDBCursor's value.|
|IDBDatabase||Represents a database connection for the purpose of conducting a transaction.|
|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.|
|IDBOpenDBRequest||Provides access to the result of a request to open a 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; no longer in spec.
Used to change the version of the database.
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 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.
An IndexedDB database is unique for our domain. So if we set up a database only we are going to be able to see it and the Object stores inside of it. If you use a shared domain, then everyone sharing your domain will be able to access and work with the data in your IndexedDB.
- Firefox will just ask the user for permission for blobs bigger than 50 MB. Reference
- For Google Chrome, see the reference on temporary storage
- Internet Explorer will ask the user for permission for Data Stores bigger than 10MB Users can also choose to allow websites to exceed the quota. Users can also change the default 10mb quota in Internet Options > Browsing History > Settings > Caching and Databases. Enterprises can also increase this setting globally or per domain using Group Policy.
- Windows 8 Apps Each app has a quota of 250MB. Among all apps on the device, the limit is 4% of the disk size or 20GB, whichever is smaller. For hard drives that are less than 30GB, the limit among all apps on the device is 375MB. Because of the overall quota among all apps, test your app to ensure it functions properly when it can store very little or even no data because other apps consume the overall quota. See: 
Tutorials and Walkthroughs:
- MDN: Storing images and files in IndexedDB
- HTML5 Rocks: A simple TODO list using HTML5 IndexedDB
- MSDN: How to create a tag cloud using IndexedDB
- 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.