WebAPI/DeviceIndexedDB

From MozillaWiki
< WebAPI
Revision as of 06:55, 14 July 2013 by Thinker (talk | contribs) (Created page with "IndexedDB is widely used for WebApps as a storage at devices. However, data stores of IndexedDB are private for the App, and it can not be used for sharing data among Apps. ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

IndexedDB is widely used for WebApps as a storage at devices. However, data stores of IndexedDB are private for the App, and it can not be used for sharing data among Apps. DeviceIndexedDB is intent to be a way of sharing data among Apps and can be queried.

What is different from DataStoreAPI?

DataStoreAPI is supposed for sync data among Apps. It is not for querying objects in the store. IndexedDB provide a good feature for querying objects, and DeviceIndexedDB extend it to share data among Apps and get access controlling.

API

DeviceIndexedDB is a modification of IndexedDB. Here only depicts changes introduced by DeviceIndexedDB.

  var request = window.deviceIndexedDB.open("ADeviceDatabase")

This function is used to open or create a database. It returns an DOMRequest, then everything is exactly like what IndexedDB is.

MANIFEST

 {
   name: "My Applicaiton",
   ......
   deviceIndexedDB: {
       "database1": {
           "store1": {                // name of the object store
               "ObjectStore": "none", // can be "none", "read-only",
                                      // "read-write"
               "index": {
                   "index-name-1": ["key1", "key2", ...], // allowed to
                                      // get objects with given keys
                   "index-name-2": [......]
               }
           }
       },
       "database2": {......}
   }
 }