Access the Database (DB)
Three types of databases are available to access data in JourneyApps: DB
, OnlineDB
and LocalDB
. Each of these is described below.
DB
The standard database (designated by DB
in JavaScript/TypeScript) in JourneyApps is accessible whether the app has access to the internet or not. All data is locally stored on the device, and changes to the data are synced to the JourneyApps Backend using our Store and Forward functionality.
All documentation regarding queries or the manipulation of database objects will assume that DB
will be used.
OnlineDB
In some cases it may be desired to run a query directly against the JourneyApps Backend, instead of the local database. In most cases it is better to use the local database, so that the application can function offline, but in some cases it may require too much data to be synchronized.
OnlineDB is an alternative for the normal DB, that performs all queries online, against the JourneyApps Backend.
Usage
Wherever DB
would normally be used, OnlineDB
can be used instead. The objects can be used in plain JavaScript/TypeScript, as well as view variables.
Keep in mind that queries and saves will have a delay, and may fail if there are network connectivity issues.
Some examples:
Displaying lists
When displaying results from an OnlineDB query in an object-list/table/dropdown, it is advised to use an array view variable instead of query view variable. This ensures that the query is only run once, and error handling can be added for situations when there is no reliable network connection.
Example:
LocalDB
In some cases an app may want to save data locally, without synchronizing the data with the server. LocalDB is an alternative database that does not upload any changes, and does not download any data from the server.
A typical use cases is to create data to display in a temporary list.
Usage
Wherever DB
would normally be used, LocalDB
can be used instead. The objects can be used in plain JavaScript/TypeScript, as well as view variables.
Some examples:
Last updated