IndexedDB – MSDN version

22Dec11

[This documentation is preliminary and is subject to change.]

Windows Internet Explorer 10 and Metro style apps using JavaScript support the Indexed Database API (:IndexedDB”). IndexedDB enables you to store structured data. Unlike cookies and DOM Storage, IndexedDB provides features that enable you to group, iterate, search, and filter JavaScript objects.

The IndexedDB API is defined by the World Wide Web Consortium (W3C)’s Indexed Database API specification, which is currently in the Working Draft stage.

IndexedDB objects

The IndexedDB API consists of several objects, each designed for specific tasks:

  • Data is stored in object stores, which are collections of JavaScript objects whose attributes contain individual values.
  • Each JavaScript object, sometimes called a record, in an object store has a common attribute called a key path; the value of this attribute is called a key value (or key). Key values uniquely identify individual records within an object store.
  • An index organizes objects according to the value of a common attribute. Indexes return sets of key values that can be used to obtain the individual records from the original object store.
  • cursor represents a set of values. When an index defines a cursor, the cursor represents the set of key values returned by the index. When an object store defines a cursor, the cursor represents a set of records stored in the cursor.
  • keyRange defines a range of values for an index or a set of records in an object store; key ranges allow you to filter cursor results.
  • database contains the object stores and indexes; databases also manage transactions.
  • request represents individual actions taken against objects in a database. For example, opening a database leads to a request object and you define event handlers on the request object to react to the results of the request.
  • transaction manages the context of operations and is used to maintain the integrity of database activities. For example, you can create object stores only in the context of a version change transaction. If a transaction is aborted, all operations within the transaction are canceled.

Asynchronous versus Synchronous

The Indexed Database API specification defines two APIs: a synchronous API and an asynchronous one. Internet Explorer 10 supports the asynchronous API. As a result, database operations do not execute immediately; instead operations return request objects that are executed in the background. Consequently, IndexedDB is an event-driven API. You create requests and then define event handlers to respond to the success or failure of those requests.

The following linked topics show you how to use IndexedDB to open a database, create transactions, and accomplish common database tasks:

 

Advertisements


One Response to “IndexedDB – MSDN version”

  1. Fantastic post however I was wondering if you could write
    a litte more on this topic? I’d be very thankful if you could elaborate a little bit further. Kudos!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: