Depot allows you to store JavaScript objects in a database. Currently implemented as a framework wrapper around HTML5 active record access.
Parameters | Type | Description |
---|---|---|
options | Object | Options for creating/opening a depot |
onSuccess | Function | Function called if depot is created or opened successfully |
onFailure | Function | Function called if depot fails to be created or opened. Passed error string. |
options object properties:
Property | Type | Description |
---|---|---|
name | String | Name of the depot. Currently mapped to an HTML5 database name. |
version | Number | Version for the depot. (optional) |
displayName | String | Name displayed in the UI for the database. Not currently used. (optional) |
estimatedSize | Number | Estimated size of the database. (optional) |
replace | Boolean | True to cause any existing data for the depot being opened to be deleted and a new, empty depot to be created. Defaults to False. |
filters | Array | Array of strings that objects in the depot can use as filters (optional) |
identifiers | {String:(Function|Object), ...} | Hash containing key-value pairs of identifiers with either constructor functions or objects whose constructor functions will be used (optional) |
Example usage:
var db= new Mojo.Depot ({name:”myDB”,version:1,replace:false}, this.openOK, this.openFail);
FeedListAssistant.prototype.dbOpenOK = function() { Mojo.Log.info("........","Database opened OK"); db.get("feedList", this.updateList.bind(this), this.useDefaultList.bind(this)); };
FeedListAssistant.prototype.dbOpenFail = function(transaction, result) { Mojo.Log.warn("Can't open feed database (#", result.message, "). All feeds will be reloaded."); Mojo.Controller.errorDialog("Can't open feed database (#" + result.message + "). All feeds will be reloaded."); };
0 Comments