Syncing SQL & loading local Data

Key:
Sync data from the cloud Use a
sync-entitiesaction to fetch data from the cloud and store it in the local SQLite database. Use theonLoad,onFocus,onRefresh, or any other event where actions are defined.Load data from SQLite to use on a jig Use the
DATA_PROVIDER_LOCALin the datasource defined in the jig or a global datasource to execute an SQLite query.Save data to SQLite ONLY To save data locally only and not sync to the cloud, use an
execute-entityaction with theDATA_PROVIDER_LOCAL.Save data to SQLite and sync data to the cloud Update the local SQLite and sync to the cloud in a single action to ensure high-performing user experiences without lag. Use
execute-entityorexecute-entitiesactions withDATA_PROVIDER_RESTorDATA_PROVIDER_SQL. Specify the function call to make, the local entity/table to update, and the method to perform on the local table. If the method is an update, delete, or save, specify the record's ID.Save data to the cloud ONLY Use
execute-entityorexecute-entitiesactions withDATA_PROVIDER_RESTorDATA_PROVIDER_SQL. Set the method to functionCall and specify the function to be called. The local tables will not be updated; you must sync the data from the cloud before it is available to display on a jig.
Using sync-entities action
Use the
sync-entitiesaction to sync data from the remote data store (REST and SQL) to the local SQLite data provider. Syncing data locally results in high performance with minimal lag and ensures that all data is available in the app when the device is offline.Best practice is to configure a global action, the
sync-entitiesaction, with the REST or SQL data provider, allowing reuse throughout the solution.Add the global sync action to the
onFocusandonLoadevents in the index.jigx file ensures data is synced to the local data provider as soon as the app loads or is focused on the device.Add the global sync action to the
onRefreshoronFocusevents in a jig when data is changed, for example, on the list of customers, this ensures that when a new customer is created, the list is updated immediately when navigating to it or refreshing the list with a downward swipe.
Using Execute-entity/entities action
There are two options when using the execute-entity and execute-entities actions with remote data such as REST or SQL.
To update BOTH the local SQLite table and the remote data store (REST and SQL). To update the local table, specify CREATE, UPDATE, or DELETE methods in the
methodproperty of the data provider, then specify the function to use in thefunctionproperty, and underparametersspecify the exact data to be updated in the remote data store (REST/SQL). Underdataspecify the exact data to be updated in the local SQLite table. After execution, a tempId is created, and then it is synced to the local table.

To ONLY update the remote data store (REST and SQL). To update the remote data store specify
functionCallin the method property. Then specify the function to be called in thefunctionproperty and underparametersspecify the exact data to be updated. Note that the data will not be visible on the jig until async-entitiesaction is executed.

Consideration
Using the
savemethod inexecute-entity/entitiesaction will perform an upsert in the local SQLite table.Dealing with offline remote data is fundamental to ensuring data synchronization and consistency between the mobile app and the remote data source, allowing users to continue using the app and performing actions without interruption. Offline remote data handling explains how to configure solutions to deal with data when the device is offline.
Using local data provider in a jig's datasources
Once the data has been synced using the
sync-entitiesaction the data is available in the local data provider.Reference the local data provider in the jig's
datasourceproperty to define the data required in the jig.Write a SQLite query to define the exact data required.
Use Intellisense and expressions to reference the specific datasource values to use in each component, such as
data: [email protected]

Last updated
Was this helpful?