Skip to content

Instantly share code, notes, and snippets.

@slackorama
Created June 23, 2009 23:50
Show Gist options
  • Save slackorama/134919 to your computer and use it in GitHub Desktop.
Save slackorama/134919 to your computer and use it in GitHub Desktop.
check to see if item exists in store and insert it.
function processData(item, request){
var value = myStore.getValue(item, 'group');
var exist = myStore.getValue(item, value);
var child = myStore.getValue(item, "name");
console.debug(exist);
if (undefined == exist){
console.debug(exist + " Create " + value + " " + child);
myStore.newItem({name: value, children:[{_reference: [child]}]});
myStore.save;
}
}
var data = { identifier: 'name', label: 'name', items: [{ name:"Egypt", type:"country", group:"Africa" }]};
dojo.require('dojo.data.ItemFileWriteStore');
var myStore = new dojo.data.ItemFileWriteStore( { data: data });
myStore.fetch( { onItem: processData});
myStore.fetch( { onItem: function(item) { console.log( myStore.getValue( item, "name") ) } });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment