indexeddb

< apis
Revision as of 18:51, 18 November 2012 by Carlos reynosa (Talk | contribs)

Jump to: navigation, search

IndexedDB reference


W3C Working Draft

Summary

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.

Usage

indexedDB = window.indexedDB;

Notes

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

Constructs

Database

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.

Keys

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

Values

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

Index

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.

Cursor

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

Transaction

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.

Request

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.

Security

The IndexedDB storage follows the same-origin policy.

Storage Limits


See also

External resources

Wrappers

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