Schemas

A schema describes data structures that do not need to be persisted in the global data model. A schema can represent simple values, nested objects, and lists, making it usable in data bindings, action params, and flows without first being modelled as an object class.

Schemas are useful when working with data that lives outside Appfarm - the response of a web request, a payload from an external system, or any structured data that a solution needs to use once but not store.

Defining a schema

A schema is defined inline, as a data type on an action variable or action param. When you set the data type to schema, the Edit schema dialog opens where you define the properties directly.

Schema editor

Each property has a key and a data type. The supported data types are:

  • String (with Timestamp, Secret and Internet URL sub types)

  • Number (with Integer and Float sub types)

  • Boolean

  • Object

  • Array (can be of any of the four other data types)

Nesting works the same way at any depth, so a schema can describe arbitrarily structured data. The top level of a schema is itself either an object or an array, which means a single schema can describe one record or a collection of them.

Schemas can also be created automatically when generating a flow from an OpenAPI specification. The OpenAPI import sets up schemas as action variables on the flow, matching the structure declared in the spec.

Using schemas

Schemas can be used wherever the platform needs to know the shape of data.

As action params. An action param can have a schema as its data type, allowing structured data to be passed into an action. The same mechanism is available for actions in apps.

As the output of a flow. An action variable on a flow can have a schema as its data type, and the calling action receives the structured data in that schema shape as part of the flow's output.

Mapping schema data to the database. When schema data should be persisted, it can be mapped into an object class using regular databindings on the Create Object or Update Object action nodes.

Schemas in action nodes

Schema data is consumed and produced by the standard action nodes — Create Object, Update Object, Delete Object, and Foreach all accept schema-typed inputs and targets. Full behavior and examples live on each node's reference page. A few patterns are specific to schemas and worth naming here:

  • On Create Object, Replace existing object defaults to false for array-typed schema properties, so new objects are appended rather than overwriting the array.

  • On a cardinality-one schema, running Create Object a second time raises an error rather than silently replacing the existing object.

  • A single Foreach node descends through one array level only — to iterate a nested array, nest a second Foreach inside the first.

Last updated

Was this helpful?