Contents
Deprecated, dojo/store will eventually replace the dojo/data API.
The most fundamental API of dojo.data is the Read API. All stores will implement this API because all stores need the ability to retrieve and process data items. The Read API is designed to be extremely flexible in how items are handled. The Read API provides the ability to:
The following examples, guidelines, and complete API documentation provide further information on the Read API:
var store = new some.Datastore();
var features = store.getFeatures();
for(var i in features){
console.log("Store supports feature: " + i);
}
var store = new some.Datastore();
if(store.isItem(someObject)){
console.log("Object was an item.");
}else{
console.log("Object was NOT an item.");
}
var store = new some.Datastore();
... // Assume that someItem is an item we got from a load.
var attributes = store.getAttributes(someItem);
for(var i = 0; i < attributes.length; i++){
console.log("Item has attribute: " + attributes[i]);
}
var store = new some.Datastore();
...
// Assume that someItem is an item we got from a load.
if(store.hasAttribute(someItem, "foo")){
console.log("item has attribute foo.");
}else{
console.log("item DOES NOT have attribute foo.");
}
var store = new some.Datastore();
...
// Assume that someItem is an item we got from a load.
var label = store.getLabel(someItem);
console.log("item has label: " + label);
var store = new some.Datastore();
var gotItems = function(items, request){
console.log("Number of items located: " + items.length);
};
store.fetch({onComplete: gotItems});
Further examples of the API usage are covered in the Using Datastores section. Refer to it for examples on paging, sorting, selecting, and so forth.
API Reference: dojo.data.api.Read