Creating Model Schemas

Creating a model schema is optional but gives you full control over the fields available in the model. If a schema is not defined, schemas will be generated on-the-fly based on the currently selected data (30 rows of the current page). This means that if you have a NoSQL dataset, the schema might differ per page. Defining a schema will ensure consistency across pages.

A schema is defined in a JSON object where the keys are the field names of your dataset.

Automatic Schema Generation

Automatic schema generation works by analyzing the data inside your dataset. It will try to resolve data types and relationships. Although the resulting schema doesn't make use of all Immuto's functionality it will be better than the on-the-fly schemas.

To generate the schema automatically, simply press the "Generate Schema" button which is located on the Schema tab of the Model Editor dialog.

Manual Schema Definition

To unleash the full potential of Immuto, a schema must be defined manually. The automatically generated schema can be used as a starting point.

The schema is a JSON object. On the first level, the field names of your dataset are placed. The second level are objects with several mandatory and optional fields.

The following JSON snippet will illustrate this:

{
  "username": {
    "type": "string"
  }
}

The fields that can appear in the second level are described in the following chapters.

type

The type field is mandatory. It specifies the datatype of this field. The type is mainly used to determine how to best represent the value in Immuto. Having selected the "wrong" type will not have impact on the usability of Immuto, but it will most likely make working with your data harder. The following types can be chosen:

  • string
  • number
  • boolean
  • date
  • binary
  • reference
  • virtual

default

Unrelated to the type defined, a default value can always be provided. For the time being this value must be static (i.e. not calculated at runtime).

Note: The default value will be used only when creating new records, not when updating them.

sortable

A boolean field that determines whether the field can be sorted on or not using Immuto. To ensure performant sorting, make sure an index exists on those fields that are set as sortable. Immuto will never modify your data structure so creating indexes is the responsibility of the user.

alias

An alias for this field which is shown to users of Immuto.

showInOverview

Whether the field should be shown in the tabular data overview of Immuto, or hidden. The field will still appear in the create and edit dialogs.

format

Especially powerful on date or number fields. The format determines how to represent the value.

For dates, a list of supported tokens can be found here.

For numbers, a list of supported formats can be found here.

to

Only used when type is a reference

The value should be the target schema's internal name that this field connects to (i.e. has a relationship with). This target schema must exist in the Immuto configuration too, otherwise it will be ignored.

enum

If the field's value must be one of a specific set of values, the enum field can be defined. This is an array of values which will be offered in a dropdown menu to the enduser.

action

The action field indicates the main action that this field represents. This is especially useful for fields of the boolean type. Setting the action field will enabe additional options in the record's dropdown menu (e.g. soft deleting records or archiving records) which will simply flip the field's boolean value.

Possible values are:

  • delete
  • archive

Table of Contents

Was this article helpful?

Thanks for your feedback!