This API is available on Firefox OS for internal applications 仅。
navigator.getDataStores()
method provides access to a list of the
Data Store API
data stores available on the device.
navigator.getDataStores('contacts').then(function(stores) {
// do something with the array of data stores in stores
});
storeName
The name of the data store you want to return. An array is returned because there may be multiple data stores with the same name.
A
Promise
object that will resolve with an array of
DataStore
对象。
navigator.getDataStores('contacts').then(function(stores) {
stores[0].getLength().then(function(storeLength) {
if(storeLength == 0) {
for(i = 0; i < contactsInit.length; i++) {
addContact(stores[0],contactsInit[i]);
};
} else {
var cursor = stores[0].sync();
runNextTask(cursor);
}
});
});
| 规范 | 状态 | 注释 |
|---|---|---|
| Data Store API | 草案 | The discussion concerning this API's creation happened in various Mozilla mailing lists and other places. A summary of the discussion and further pointers can be found on the Mozilla Wiki . For further feedback and questions, send mail to the dev-webapi mailing list. |
Available in web workers in Firefox OS 2.0.