Model Template

Developer page

Template manager page

Model Templates *.json File Structure

Which template properties are available in a model .json definition file, or in a form .json definition file?

  • For data models templates structure, see here, this file. For reference, also open this file CoreCore.json to the side, in a new browser window.
  • For forms templates structure, see here.

In the table below, the values in column "Property" correspond to keys in a *.json* file, e.g. backend/dis_templates/models/CoreCore.json.

The key ordering in the .json file is arbitrary, and can deviate from this order:

Property Type Required Nullable
module string Yes No
name string Yes No
fullName string Yes No
table string Yes No
importTable string Yes Yes
parentModel string Yes Yes
columns array of Column Yes No
indices array of Index Yes No
foreignkeys array of ForeignKey Yes No
createdAt number No Yes
modifiedAt number No Yes
generatedAt number No Yes

Model module

The name of the module that this model belongs to or, in other words, the table groups that this table belongs to.

  • is required
  • type: string
  • case: PascalCase

Model name

The name of the model.

  • is required
  • type: string
  • case: PascalCase

Model fullName

Is a combination of the module and name properties, simply concatenation of these properties.

  • is required
  • type: strings
  • case: PascalCase

Model table

The table name in the DB where the records of the data model are stored. Naming of the table should follow a strict rule that is it must be the same fullName property but written in a snake_case format.

  • is required
  • type: string
  • case: snake_case

Model importTable

used only when migrating from a legacy mDIS.

  • is optional
  • type: string

Model parentModel

The fullName of the parent model

  • is optional
  • type: string
  • case: PascalCase

Model columns

An array of columns definitions that the table has. Every object of this array is of Column type. The array must have at least one columns id that used as the primary key of the table.

Column Definition

Property Type Required Nullable
name string Yes No
importSource string Yes Yes
type string Yes No
size integer Yes No
required boolean Yes No
primaryKey boolean No Yes
autoInc boolean No Yes
label string Yes No
description string Yes No
validator string Yes No
validatorMessage string Yes Yes
unit string Yes Yes
selectListName string Yes Yes
calculate string Yes Yes
defaultValue any Yes No

Column name

The name of the column.

  • is required
  • type: string
  • case: snake_case

Column importSource

used only when migrating from a legacy mDIS.

  • is required
  • type: string

Column type

the type of the column.

  • is required
  • type: string
  • can only have one of the following values integer, double, string, boolean, dateTime, date, time

Column size

The size of the table column. This value has an effect only on integer and string columns.

  • is required
  • type: string

Column required

If this column is required. This will be generated as a validation rule in data models and frontend.

  • is required
  • type: boolean

Column primaryKey

Used only by import.

  • is required
  • type: boolean

Column autoInc

Used only by import.

Define the column as an auto-incremented primary key. Only ONE column can has this value set to true which is the id column i.e. this field should always be false.

  • is required
  • type: boolean

Column label

The value of this field is used as a field label in forms.

  • is required
  • type: string

Column description

The value of this field is used as a hint label in forms.

  • is optional
  • type: string

Column validator

This field defines the validation rules for a column value. It accepts the multiple formats. If the written format does not match one of the supported ones, it will be ignored.

  • is optional
  • type: string
Supported validator formats
  • compare operators: >, <, >=, <=, <>, != appended with the value to compare with.
  • between ... and ...: for a range validator
  • in [..., ..., ...]: for a enum validator
  • LIKE regex: string regex validator

Column validatorMessage

A custom validation message to be shown in case the value was not valid.

  • is optional
  • type: string

Column unit

Used only by import.

  • is optional
  • type: string

Column selectListName

Used only by import

The name of the list to select the values from. This value will be used when generating the form to show a suitable select input.

  • is optional
  • type: string

Column calculate

Define this if the column value should be calculated based on other columns. It supports limited operations +, -, /, * and parentheses () and functions ABS(). The columns are represented by there names inside brackets e.g. [bottom_depth]

  • is optional
  • type: string

Column defaultValue

The default value of the column

  • is optional
  • type: string

Model indices

An array of indices definitions that the table has. Every object of this array is of Index type. The array must have at least one index on id column that represent the primary key of the table.

Index Definition

Property Type Required Nullable
name string Yes No
type string Yes No
columns array of strings Yes No

Index Name

Name of the index

  • is required
  • type: string

Index Type

Type of the index can have one of the following values: PRIMARY, KEY, UNIQUE

  • is required
  • type: string

Index Columns

An array of columns names that forms the index value.

  • is required
  • type: array of strings

Model foreignkeys

An array of foreign keyes definitions that the table has. If the model has a parent model a foreign key will be automatically generated in the template manager that represents the relation. Every object of this array is a ForeignKey type.

ForeignKey Definition

Property Type Required Nullable
name string Yes No
foreignTable string Yes No
localColumns array of strings Yes No
foreignColumns array of strings Yes No

ForeignKey name

Name of the key

  • is required
  • type: string

ForeignKey foreignTable

The name of the foreign table

  • is required
  • type: string

ForeignKey localColumns

An array of columns names that forms the key value.

  • is required
  • type: array of strings

ForeignKey foreignColumns

An array of columns names in the foreign table that forms the reference value.

  • is required
  • type: array of strings

Model createdAt

A timestamp of when the template was created

  • is optional
  • type: integer

Model modifiedAt

A timestamp of when the template was modified

  • is optional
  • type: integer

Model generatedAt

A timestamp of when the template was generated

  • is optional
  • type: integer