Constructordojox.data.jsonPathStore

dojo.require("dojox.data.jsonPathStore");
defined in dojox/data/jsonPathStore.js

jsonPathStore constructor, instantiate a new jsonPathStore Takes a single optional parameter in the form of a Javascript object containing one or more of the following properties. data: /JSON String/ || / Javascript Object /, JSON String or Javascript object this store will control JSON is converted into an object, and an object passed to the store will be used directly. If no data and no url is provide, an empty object, {}, will be used as the initial store. url: / string url / Load data from this url in JSON format and use the Object created from the data as the data source. indexOnLoad: / boolean / Defaults to true, but this may change in the near future. Parse the data object and set individual objects up as appropriate. This will add meta data and assign id's to objects that dont' have them as defined by the idAttribute option. Disabling this option will keep this parsing from happening until a query is performed at which time only the top level of an item has meta info stored. This might work in some situations, but you will almost always want to indexOnLoad or use another option which will create an index. In the future we will support a generated index that maps by jsonPath allowing the server to take some of this load for larger data sets. idAttribute: / string / Defaults to '_id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index. There are utility routines for exporting data from the store that can clean any generated IDs before exporting and leave preexisting id's in tact. metaLabel: / string / Defaults to '_meta' overrides the attribute name that is used by the store for attaching meta information to an object while in the store's control. Defaults to '_meta'. hideMetaAttributes: / boolean / Defaults to False. When enabled, calls to getAttributes() will not include the meta attribute. autoIdPrefix: /string/ Defaults to "_auto_". This string is used as the prefix to any objects which have a generated id. A numeric index is appended to this string to complete the ID mode: dojox.data.ASYNC_MODE || dojox.data.SYNC_MODE Defaults to ASYNC_MODE. This option sets the default mode for this store. Sync calls return their data immediately from the calling function instead of calling the callback functions. Functions such as fetchItemByIdentity() and fetch() both accept a string parameter in addtion to the normal keywordArgs parameter. When passed this option, SYNC_MODE will automatically be used even when the default mode of the system is ASYNC_MODE. A normal request to fetch or fetchItemByIdentity (with kwArgs object) can also include a mode property to override this setting for that one request.

Usage

function (options) (view source)
parametertypedescription
options  

Jump to PropertiesFunctionsBack to top

FunctionbuildIndex(path: String, item)
parse the object structure, and turn any objects into jsonPathStore items. Basically this just does a recursive series of fetches which itself already examines any items as they are retrieved and setups up the required meta information.
FunctioncleanMeta(data, options)
Recurses through 'data' and removes an meta information that has been attached. This function will also removes any id's that were autogenerated from objects. It will not touch id's that were not generated
FunctioncontainsValue(item: Object, attribute: String, value)
Checks to see if 'item' has 'value' at 'attribute'
FunctiondeleteItem(item)
deletes item and any references to that item from the store. If the desire is to delete only one reference, unsetAttribute or setValue is the way to go.
Functiondump(options)
exports the store data set. Takes an options object with a number of parameters data: /* object */ Defaults to the root of the store. The data to be exported. clone: /* boolean */ clone the data set before returning it or modifying it for export cleanMeta: /* boolean */ clean the meta data off of the data. Note that this will happen to the actual store data if !clone. If you want to continue using the store after this operation, it is probably better to export it as a clone if you want it cleaned. suppressExportMeta: /* boolean */ By default, when data is exported from the store some information, such as as a timestamp, is added to the root of exported data. This prevents that from happening. It is mainly used for making tests easier. type: "raw" || "json" Defaults to 'json'. 'json' will convert the data into json before returning it. 'raw' will just return a reference to the object
Functionfetch(args)
console.log("fetch() ", args); fetch takes either a string argument or a keywordArgs object containing the parameters for the search. If passed a string, fetch will interpret this string as the query to be performed and will do so in SYNC_MODE returning the results immediately. If an object is supplied as 'args', its options will be parsed and then contained query executed. query: /* string or object */ Defaults to "$..*". jsonPath query to be performed on data store. **note that since some widgets expect this to be an object, an object in the form of {query: '$[*'], queryOptions: "someOptions"} is acceptable mode: dojox.data.SYNC_MODE || dojox.data.ASYNC_MODE Override the stores default mode. queryOptions: /* object */ Options passed on to the underlying jsonPath query system. start: /* int */ Starting item in result set count: /* int */ Maximum number of items to return sort: /* function */ Not Implemented yet The following only apply to ASYNC requests (the default) onBegin: /* function */ called before any results are returned. Parameters will be the count and the original fetch request onItem: /*function*/ called for each returned item. Parameters will be the item and the fetch request onComplete: /* function */ called on completion of the request. Parameters will be the complete result set and the request onError: /* function */ colled in the event of an error
fetch an item by its identity. This store also provides a much more finger friendly alias, 'byId' which does the same thing as this function. If provided a string this call will be treated as a SYNC request and will return the identified item immediatly. Alternatively it takes a object as a set of keywordArgs: identity: /* string */ the id of the item you want to retrieve mode: dojox.data.SYNC_MODE || dojox.data.ASYNC_MODE overrides the default store fetch mode onItem: /* function */ Result call back. Passed the fetched item. onError: /* function */ error callback.
Gets the available attributes of an item's 'property' and returns it as an array. If the store has 'hideMetaAttributes' set to true the attributed identified by 'metaLabel' will not be included.
return the store feature set
FunctiongetLabel(item)
FunctiongetValue(item: Object, property)
Gets the value of an item's 'property'
FunctiongetValues(item: Object, property)
Gets the value of an item's 'property' and returns it. If this value is an array it is just returned, if not, the value is added to an array and that is returned.
FunctionhasAttribute(item: Object, attribute: String)
Checks to see if item has attribute
FunctionisDirty(item)
FunctionisItem(item: Object)
Checks to see if a passed 'item' is really a jsonPathStore item. Currently it only verifies structure. It does not verify that it belongs to this store at this time.
FunctionloadItem(item)
FunctionnewItem(data: Object, options: Object)
adds a new item to the store at the specified point. Takes two parameters, data, and options.
FunctiononLoadData(data)
Called after data has been loaded in the store. If any requests happened while the startup is happening then process them now.
notification of the revert event..not part of the notification api, but probably should be.
FunctiononSave(items)
notification of the save event..not part of the notification api, but probably should be. console.log("onSave() ", items);
Functionsave(kwArgs)
Takes an optional set of keyword Args with some save options. Currently only format with options being "raw" or "json". This function goes through the dirty item lists, clones and trims the item down so that the items children are not part of the data (the children are replaced with reference objects). This data is compiled into a single array, the dirty objects are all marked as clean, and the new data is then passed on to the onSave handler.
FunctionsetData(data)
set the stores' data to the supplied object and then load and/or setup that data with the required meta info
FunctionsetValue(item, attribute, value)
sets 'attribute' on 'item' to 'value'
FunctionsetValues(item, attribute, values)
sets 'attribute' on 'item' to 'value' value must be an array.
Functionsort(a, b)
FunctionunsetAttribute(item, attribute)
unsets 'attribute' on 'item'
Function_addReference(item, pInfo)
adds meta information to an item containing a reference id so that references can be deleted as necessary, when passed only a string, the string for parent info, it will only it will be treated as a string reference
make sure we have an reference to the item in the store and not a clone. Takes an item, matches it to the corresponding
Create a small reference object that can be used to replace child objects during a trim
Function_loadData(data)
load data into the store. Index it if appropriate.
Function_markClean(item)
remove this meta information marking an item as "dirty"
Function_mixin(target, data)
specialized mixin that hooks up objects in the store where references are identified.
Function_setDirty(item)
adds an item to the list of dirty items. This item contains a reference to the item itself as well as a cloned and trimmed version of old item for use with revert.
does a simple/shallow compare of properties on an object to the same named properties on the given item. Returns true if all props match. It will not descend into child objects but it will compare child date objects
Function_trimItem(item)
copy an item recursively stoppying at other items that have id's and replace them with a refrence object;
Function_updateMeta(item, props)
verifies that 'item' has a meta object attached and if not it creates it by setting it to 'props' if the meta attribute already exists, mix 'props' into it.

Jump to FunctionsPropertiesBack to top