relation | relations
The relation and relations properties are used to define a relationship from an atom to elements, molecules and ions. Useful for creating links between content, such as navigation or links on a page or referencing other reusable content.
These definitions are references that can define how the relationship is output in the API. They can be circular and/or self-referential without causing infinite loops.
Relation
import { atom, relation } from '@iridiumcms/core';
export const sample = atom('sample', {
myLink: relation('page'),
});
The relation field defines a one-to-one relationship. It takes either an atom name and optional configuration object or a optional configuration object:
- nameAn allowed list of element, molecule, or ion names.
string | string[] - depthThe default depth of the relationship to populate in the API. Defaults to
numberInfinity. - displayNameThe display name of the field. Defaults to the name of the property.
string - requiredWhether the field is required. Defaults to
booleanfalse. - layoutThe layout of the field in the admin. Defaults to
LAYOUTLAYOUT.full.
Relations
import { atom, relations } from '@iridiumcms/core';
export const sample = atom('sample', {
myLinks: relations([
'page',
'post',
]),
});
The relations field defines a one-to-many relationship. It takes either a list of atom names and optional configuration object or a optional configuration object:
- namesAn allowed list of element, molecule, or ion names.
string[] - depthThe default depth of the relationship to populate in the API. Defaults to
numberInfinity. - minThe minimum number of relationships. Defaults to
number0. - maxThe maximum number of relationships. Defaults to
numberInfinity. - isRepeatableAllows multiple of the same relationship to be created. Defaults to
booleantrue. - displayNameThe display name of the field. Defaults to the name of the property.
string - requiredWhether the field is required. Defaults to
booleanfalse. - layoutThe layout of the field in the admin. Defaults to
LAYOUTLAYOUT.full.
