Version 24, changed by brian 09/13/2006. Show version history
These are the design notes for teh Data Store API in the dojo.data package.
For background and context, see
The files shown on this page are interface definitions, not class implementations. The complete Data Store API is comprised of 8 or 10 different parts. A data store can implement one or more of the parts. The first two parts, Read and Write are each documented on their own wiki pages -- this dojo.data.api page includes the contents of those separate pages via transclusion:
/****** Notification API ******/ // *FIXME* // We need some way to handle notifications -- some way for // widget controllers to register interest in data items or // subscribe to be notified of changes to the data items.
/****** Metamodel/Schema read-only API ******/
store.getMetamodel()
store.getAllDataClasses()
store.getDataClassOf(kermit)
store.getDataClass("Muppet")
store.getAttributesOf(muppet)
store.getAttribute("color")
store.getAllAttributes()
store.hasAttribute("color")
store.compare("color", kermit, elmo)
dojo.data.GREATER_THAN
dojo.data.LESS_THAN
dojo.data.EQUAL_TO
store.getSortFunction({direction: dojo.data.ASCENDING, attribute: "population"});
dojo.data.ASCENDING
dojo.data.DESCENDING
/****** Metamodel/Schema read-write API ******/ store.newItemOfClass(muppet) store.newAttribute()
/****** Versioning API ******/ store.setContextToVersionKey(); store.setContextToCurrentVersion(); store.getCurrentVersionKey();
/****** Attribution API ******/ store.getUserWhoCreated(kermit); store.getUserWhoLastEdited(kermit);
/****** Data-types API ******/ dojo.data.Types.DATETIME dojo.data.Types.NUMBER dojo.data.Types.IMAGE dojo.data.Types.TEXT value.getType() value.toString()
/****** DataStore Factory API ******/
dojo.data.registerStore("delicious", dojo.data.store.Delicious);
var store = dojo.data.newStore({type: "delicious"})
var store = dojo.data.newStore({uri: "foo/bar/states.csv"});
/****** Transaction Mixin ******/ store.beginTransaction() store.endTransaction() // We may want to have an optional file that implements a couple simple // methods for handling nested transactions: store.beginTransaction(); store.set(kermit, "color", "green"); store.beginTransaction(); store.set(elmo, "color", "red"); store.endTransaction(); store.endTransaction(); // The outermost call to store.endTransaction() would cause a call to // store.save(). Any inner calls to store.endTransaction() are no-ops. // This looks silly in the simple example above, but it is handy to have // when you're trying to write code with re-usable functions and minimize // dependencies. // These beginTransaction() and endTransaction() methods could be // coded independently of any specific data store implementation, // and then the beginTransaction/endTransaction code could be mixed // in to any data store by any client code that wanted to use the // beginTransaction/endTransaction feature.
/****** We haven't yet figured out if this method belongs in the API ******/
/****** If it does belong in the API, then we need to figure out where ******/
getJsonString:
function(/* item */ item) {
// summary:
// Returns a string containing a serialized JSON representation of an item.
// issue:
// Maybe this method really doesn't belong here in what's supposed to
// be a basic, minimalist read-only API. We could move this method
// to some other portion of the API, or we could cut this method entirely.
// issue:
// This method looks simple, but in fact it could be complicated
// to implement, because it requires dealing with the serialization
// of item references (think SQL foreign keys) and the serialization
// of complex literal values like Dates.
dojo.unimplemented('dojo.data.Read.getJsonString');
var jsonString = "";
return jsonString; // string
}