Models on the client represent server records. In Mobile Sync, model objects are instances of Force.SObject, a subclass of the Backbone.Model class. SObject extends Model to work with Salesforce APIs and, optionally, with SmartStore.
You can perform the following CRUD operations on SObject model objects:
Create
Destroy
Fetch
Save
Get/set attributes
In addition, model objects are observable: Views and controllers can receive notifications when the objects change.
Properties
Force.SObject adds the following properties to Backbone.Model:
sobjectType
Required. The name of the Salesforce object that this model represents. This value can refer to either a standard object or a custom object.
fieldlist
Required. Names of fields to fetch, save, or destroy.
For updatable offline storage of records. The Mobile Sync comes bundled with Force.StoreCache, a cache implementation that is backed by SmartStore.
cacheForOriginals
Contains original copies of records fetched from server to support conflict detection.
Examples
You can assign values for model properties in several ways:
As properties on a Force.SObject instance.
As methods on a Force.SObject sub-class. These methods take a parameter that specifies the desired CRUD action (“create”, “read”, “update”, or “delete”).
In the options parameter of the fetch(), save(), or destroy() function call.
For example, these code snippets are equivalent.
1// As properties on a Force.SObject instance2acc = new Force.SObject({Id: "<SOME_ID>"});3acc.sobjectType = "account";4acc.fieldlist = ["Id", "Name"];5acc.fetch();
1// As methods on a Force.SObject sub-class2Account = Force.SObject.extend({3 sobjectType: "account",4 fieldlist: function(method){5 return["Id", "Name"];6},7});8Acc = new Account({Id: "<SOME_ID>"});9acc.fetch();
1// In the options parameter of fetch()2acc = new Force.SObject({Id:"<SOME_ID>"});3acc.sobjectType = "account";4acc.fetch({fieldlist:["Id", "Name"]);
We've Moved
Welcome to the new home of the Mobile SDK Developer Guide! For now, the Japanese guide can be found in PDF form.