The most basic atom of the dojo.data
API is called an
item, which is composed of key/value pairs called
attributes and attribute
values in dojo.data
parlance; conceptually, you can think of an item as a plain old
JavaScript Object
. However,
although the underlying implementation may very well be a JavaScript
Object
, be careful to use the
provided APIs for accessing it, as the internal representation may be
something entirely different. For example, some data abstractions may
use a DOM model for storing certain types of data for efficiency
reasons, or lazy-load data on the fly even though it seems like it's
already local. In cases like these, accessing an item like a plain old
JavaScript object would likely cause an unexpected error. We'll come
back to specific API calls for accessing an item in the next
section.
Tip
Saying that an item has an attributeâbut no value for the attributeâis the same as saying that the item doesn't have the attribute at all. In other words, it's nonsensical to think about having an attribute with no value because attributes inherently have a specific state.
Before getting into the capabilities of any one specific API,
it's helpful to survey the landscape. Here's an overview of the
various dojo.data
APIs with a brief
summary of what these APIs provide to the application developer. These
APIs are interfaces, not implementations; any concrete dojo.data
data store
would define one or more of the upcoming APIs:
dojo.data.api.Read
Provides a uniform means of reading, searching, sorting, and filtering data items.
dojo.data.api.Write
Provides a uniform means of creating, deleting, and updating data items.
dojo.data.api.Identity
Provides a uniform means of accessing an item via a unique identifier.
dojo.data.api.Notification
Provides a uniform means of notifying a listener of a change, such as create, delete, or update operation, for a data item.
The remainder of this chapter systematically works through each
of these APIs and provides plenty of examples so that you can make the
most of dojo.data
in your own
application.
Get Dojo: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.