Return Types |
---|
OfflineDataDescription |
Method Summary | |
---|---|
OfflineDataDescription | #createOfflineDataDescription() Create a descriptive model for offline data. |
OfflineDataDescription | #createOfflineDataDescription(prefix) Create a descriptive model for offline data. |
Array | #getRowDescriptions(fs, pks) This method returns the description of rows as a json array object. |
void | #performSync(data, version, authenticateResult) If all the changes for a mobile client needs to come as once so that they can be in 1 transaction. |
Method Details |
---|
createOfflineDataDescription |
OfflineDataDescription createOfflineDataDescription () |
Create a descriptive model for offline data.
|
Returns |
Sample//plugins.mobile.getOfflineFoundSetData(foundset,null); var data = plugins.mobileservice.createOfflineDataDescription('data_'); |
createOfflineDataDescription |
OfflineDataDescription createOfflineDataDescription (prefix) |
Create a descriptive model for offline data.
|
Parameters {String} prefix – specified formname prefix used to retrieve row data from REST wise
|
Returns |
Sample//plugins.mobile.getOfflineFoundSetData(foundset,null); var data = plugins.mobileservice.createOfflineDataDescription('data_'); |
getRowDescriptions |
Array getRowDescriptions (fs, pks) |
This method returns the description of rows as a json array object.
|
Parameters |
Returns |
Sample/** @type {Array<Object>} */ var idsArray = new Array(100,200,300); foundset.loadAllRecords(); var json = plugins.mobileservice.getRowDescriptions(foundset, idsArray) |
performSync |
void performSync (data, version, authenticateResult) |
If all the changes for a mobile client needs to come as once so that they can be in 1 transaction. Then the offline_data form should define a ws_update method.
This method will then get the complete data package which should be give to this function. This will redispatch all the inserts,updates or deletes to the various data forms that has the real rest methods to handle the actual insert. If something fails then an Exception will be thrown and you can do a rollback so that everything of this sync is reverted. |
Parameters {Object} data – The data package that is given to the offline_data form ws_update method.
{Number} version – The version number that is given to the offline_data form ws_update method. {Object} authenticateResult – The authenticateResult object that is given to the offline_data form ws_update method. (generated by the offline_data.ws_authenticate) |
Returns void
|
Sampletry { databaseManager.startTransaction(); plugins.mobileservice.performSync(data,version,authenticateResult); databaseManager.commitTransaction(); } catch (e) { databaseManager.rollbackTransaction(); // log the error and return false to that the mobile client will know the sync did fail. application.output(e,LOGGINGLEVEL.ERROR); return false; } |