Configuring data resources
You can also view the videos in Core Lessons 3 - Data and Integrations
When we talk about data in the context of Composer apps, we mean data that is stored outside the context of the running app.
Typically, this means that the data is available online via an API, but it could also be stored on the device itself as a client-side storage.
A data resource defines access to such data, e.g. a client-side storage resource called Session or REST API integration called Incidents.
Currently, the available data resource types are:
  • On-device storage – data stored on the device/web browser itself; cannot be shared between different devices
  • REST API direct integration – direct integration to an external JSON-based API

Defining new data resources

To define a new data resource, open the Data configurator via the global toolbar at the top.
Here, you can see a list of all data resources configured for your app, and can create new ones via the Add data resource button on the top right corner.
All data resources have several common properties:
  • an unique Identifier/name, such as Movies
  • a short text description, used also when publishing the data resource for others to use via the Marketplace
  • a schema, which defines the structure and type of data stored in the resource, e.g. for a movie, Title that is a string, Runtime that is a number, and so on.
For more information on how to configure the different data resource types, see the individual guides above.

Using data from a data resource

To use data from a data resource, we need to bring it to app state. This can happen via a data variable or by using the data flow functions individually.

Data variables

The most straightforward way to use data is via data variables. They are added to a page via the variable editor, and contain default logic to populate themselves with data from the data resource. Their schema is always the same as their data resource's schema.
There are three types of data variables, chosen when you add one to a page.
  • Collection of data records
  • Single data record
  • New data record

Collection of data records

This type of data variable gives you access to multiple records fetched from the data resource. For example, all movies from a Movies resource.
Typically, the data resource defines some properties that allow you to affect what records are returned from the backend. These are configurable when using the data variable.
For example, a On-device storage resource has the Filters, Sorting criteria and Limit properties. Using them I can e.g. get all movies whose title matches "lord of the rings", sorted by release date, limited to 5 movies.
In contrast, REST API direct integrations can define any number of properties, depending on the source API.
This type of data variable is always an array of objects whose schema matches the data resource schema.

Single data record

This type of data variable gives you access to a single data record fetched from the data resource. For example, a single specific movie from a Movies resource.
Since we always want to fetch some specific record from the data resource, the data resource must define a property or properties to uniquely identify the record we're interested in.
For Client-side storage, and for most APIs, this happens by the ID property.
This type of data variable is always an object whose schema matches the data resource schema.

New data record

This type of data variable defines an empty object, e.g. a movie you haven't yet added to your database.
The difference between the new and single data record types is simply that new data record type data variables do not contain any logic to fetch data from the data resource, they simply initialize as empty.
They are most often used in forms whose purpose is to create a new record, by binding the input fields to the data variable.
This type of data variable is always an object whose schema matches the data resource schema.