Listing 1. ItemFileWriteStore Example

<html>
<head>
  <title>ItemFileWriteStore Example</title>
  <script
      type="text/javascript"
      src="http://o.aolcdn.com/dojo/1.2/dojo/dojo.xd.js">
  </script>
  <script type="text/javascript">
    dojo.require("dojo.data.ItemFileWriteStore");
    dojo.addOnLoad(
      function() {

        /* Creating a store with inline JavaScript data */
        var store = new dojo.data.ItemFileWriteStore({
          data : {
            identifier : "id",
            items : [
                     {"id" : 1, "label" : "foo"},
                     {"id" : 2, "label" : "bar"},
                     {"id" : 3, "label" : "baz"}
            ]
          }
        });

        /* Add another item - a synchronous operation */
        store.newItem({"id" : 4, "label" : "qux"});

        /* Fetch an item with id=4 - an asynchronous operation */
        store.fetch({
          query  : {id : 4},
          onItem : function(item) {
            console.log("Asynchronous callback for fetching item:",
                        item);

            /* Delete the item with id=4, a synchronous operation */
            store.deleteItem(item);

            /* Save the results */
            store.save();

            /* Could have reverted the results with
               store.revert(); */
          }
        });
      });
</script>
</head>
<body>
</body>
</html>

