www.webOShelp.net

Get the latest on:webOS Developers' RSS FeedwebOS Facebook page webOS Twitter Feed

Home Resources API Reference Mojo.Depot.add(key, value, onSuccess, onFailure)

Mojo.Depot.add(key, value, onSuccess, onFailure)

Function to add an object identified by a key to the depot. The default bucket is used.

Parameters Type Description
key String Key to identify the object being stored in the depot.  If an object already exists with the same key, it is replaced
value Object Object to store in the depot
onSuccess Function Function called when the object is successfully stored in the depot
onFailure Function Function called if the add fails.  Passed an error string.

Example usage:

db = new Mojo.Depot({name:"feedDB", version:1, estimatedSize:25000, replace: false}, 
     this.dbOpenOK.bind(this), this.dbOpenFail.bind(this)); 

db.add("feedList", feedList, 
        function() {Mojo.Log.info("........","feedList saved OK");}, 
        function(transaction,result) { 
          Mojo.Log.warn("Database save error (#", result.message, ") - can't save feed list. Will need to reload on next use."); 
          Mojo.Controller.errorDialog("Database save error (#" + result.message + ") - can't save feed list. Will need to reload on next use."); 
        });
 

0 Comments

    Add Comment


      • >:o
      • :-[
      • :'(
      • :-(
      • :-D
      • :-*
      • :-)
      • :P
      • :\
      • 8-)
      • ;-)