Changes

Jump to: navigation, search

WebAPI/DataStore

2,692 bytes added, 16:32, 12 April 2013
Created page with "= Data Store API = This is the snapshot of a discussion between Mounir Lamouri, Thinker Lee, Gene Lian, Jonas Sicking and Hsin-Yi Tsai.<br> The work drafting happened on http..."
= Data Store API =

This is the snapshot of a discussion between Mounir Lamouri, Thinker Lee, Gene Lian, Jonas Sicking and Hsin-Yi Tsai.<br>
The work drafting happened on https://etherpad.mozilla.org/whatever-you-want

== Use Cases ==

Allow an application to create data that can be shared with multiple other applications.<br>
Allow multiple applications supply data to the same data store.<br>
Support read-only stores like facebook contacts.<br>
Support read/write stores like built-in contacts.<br>
Support keeping a application-local cache of a data store. I.e. enable getting notified about changes to a data store so that the local cache can be kept up-to-date.<br>
Enforce types of attributes (avoid to break other applications).

== Interface ==

interface DataStore {
// Returns the label of the DataSource.
readonly attribute DOMString name;
// Returns the origin of the DataSource (e.g., 'facebook.com').
// TODO: defines what the value should be if owned by 'system'.
readonly attribute DOMString owner;
// is readOnly a F(current_app, datastore) function? yes
readonly attribute boolean readOnly;
// TODO: id should be incremental.
Future<Object> get(int id);
Future<void> update(int id, Object obj);
Future<int> add(Object obj);
Future<boolean> remove(int id);
Future<void> clear();
readonly attribute DOMString revisionId;
attribute EventHandler onchange;
Future<DataStoreChanges> getChanges(DOMString revisionId);
// TODO: getAll(), getLength().
};

interface DataStoreChanges {
readonly attribute DOMString revisionId;
readonly attribute int[] addedIds;
readonly attribute int[] updatedIds;
readonly attribute int[] removedIds;
}

partial interface Navigator {
Future<DataStore[]> getDataStores(DOMString name);
};

== Manifest ==

=== For the application that provides the datastore ===
{
...
datastores-owned: {
"contacts": {
"readonly": true,
"name": "Facebook contacts",
}
},
...
}

=== For the application that wants to access the datastore ===
{
...
datastores-access: {
"contacts": {
"access": "readonly",
"description": ...
}
},
...
}

== Issues ==
* {name, owner, value} is a complicated key.
* UI: what to do when we have multiple access requests?
* What's happening if the central gets changes during the process of local updates?
* |addedIds|, |removedIds| and |updatedIds| arrays should be synchronized. For example, the ID of record that has been updated and removed should only show up in the |removedIds| array. Need to define the behaviours.
Confirm
368
edits

Navigation menu