dojo/store/DataStore.js

  • Provides:

    • dojo.store.DataStore
  • dojo.store.DataStore

    • type
      Function
    • parameters:
      • options: (typeof Object)
        This provides any configuration information that will be mixed into the store,
        including a reference to the Dojo data store under the property "store".
    • source: [view]
        dojo.mixin(this, options);
    • summary
      This is an adapter for using Dojo Data stores with an object store consumer.
      You can provide a Dojo data store and use this adapter to interact with it through
      the Dojo object store API
  • dojo.store.DataStore.target

    • summary
  • dojo.store.DataStore._objectConverter

    • type
      Function
    • parameters:
      • callback: (typeof )
    • source: [view]
        var store = this.store;
        return function(item){
         var object = {};
         var attributes = store.getAttributes(item);
         for(var i = 0; i < attributes.length; i++){
          object[attributes[i]] = store.getValue(item, attributes[i]);
         }
         return callback(object);
        };
    • summary
  • dojo.store.DataStore.get

    • type
      Function
    • parameters:
      • id: (typeof Object)
        The identity to use to lookup the object
      • options: (typeof )
    • source: [view]
        var returnedObject, returnedError;
        var deferred = new dojo.Deferred();
        this.store.fetchItemByIdentity({
         identity: id,
         onItem: this._objectConverter(function(object){
          deferred.resolve(returnedObject = object);
         }),
         onError: function(error){
          deferred.reject(returnedError = error);
         }
        });
        if(returnedObject){
         // if it was returned synchronously
         return returnedObject;
        }
        if(returnedError){
         throw returnedError;
        }
        return deferred.promise;
    • summary
      Retrieves an object by it's identity. This will trigger a fetchItemByIdentity
  • dojo.store.DataStore.put

    • type
      Function
    • parameters:
      • object: (typeof Object)
        The object to store.
      • options: (typeof Object)
        Additional metadata for storing the data.  Includes a reference to an id
        that the object may be stored with (i.e. { id: &quot;foo&quot; }).
    • source: [view]
        var id = options && typeof options.id != "undefined" || this.getIdentity(object);
        var store = this.store;
        if(typeof id == "undefined"){
         store.newItem(object);
        }else{
         store.fetchItemByIdentity({
          identity: id,
          onItem: function(item){
           if(item){
            for(var i in object){
             if(store.getValue(item, i) != object[i]){
              store.setValue(item, i, object[i]);
             }
            }
           }else{
            store.newItem(object);
           }
          }
         });
        }
    • summary
      Stores an object by its identity.
  • dojo.store.DataStore.remove

    • type
      Function
    • parameters:
      • id: (typeof Object)
        The identity to use to delete the object
    • source: [view]
        var store = this.store;
        this.store.fetchItemByIdentity({
         identity: id,
         onItem: function(item){
          store.deleteItem(item);
         }
        });
    • summary
      Deletes an object by its identity.
  • dojo.store.DataStore.query

    • type
      Function
    • parameters:
      • query: (typeof Object)
        The query to use for retrieving objects from the store
      • options: (typeof Object)
        Optional options object as used by the underlying dojo.data Store.
    • source: [view]
        var returnedObject, returnedError;
        var deferred = new dojo.Deferred();
        deferred.total = new dojo.Deferred();
        var converter = this._objectConverter(function(object){return object;});
        this.store.fetch(dojo.mixin({
         query: query,
         onBegin: function(count){
          deferred.total.resolve(count);
         },
         onComplete: function(results){
          deferred.resolve(dojo.map(results, converter));
         },
         onError: function(error){
          deferred.reject(error);
         }
        }, options));
        return dojo.store.util.QueryResults(deferred);
    • summary
      Queries the store for objects.
    • return_summary
      dojo.store.util.QueryResults
      A query results object that can be used to iterate over results.
  • dojo.store.DataStore.getIdentity

    • type
      Function
    • parameters:
      • object: (typeof Object)
        The data object to get the identity from.
    • source: [view]
        return object[this.idProperty || this.store.getIdentityAttributes()[0]];
    • summary
      Fetch the identity for the given object.
    • return_summary
      Number
      The id of the given object.
  • this

    • mixins:
      • options: (normal)
    • summary
  • dojo.store

    • type
      Object
    • summary
  • dojo

    • type
      Object
    • summary