Configuring data resources
  • 09 Jun 2022
  • 3 Minutes to read
  • Dark
  • PDF

Configuring data resources

  • Dark
  • PDF

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
  • OData Integration
  • Google Firebase
  • Custom resources found on the marketplace

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:

  • Resource ID - an unique Identifier/name used to refer to the data resource.
  • Short description - a brief text description, used also when publishing the data resource for others to use via the Marketplace.
  • Resource Schema - a schema, which defines the structure and type of data stored in the resource.
  • Resource URL - external resource for data.

Using data from a data resource

To use data from a data resource, we can connect a data variable or usedata 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.

Was this article helpful?

What's Next