Iridium CMSIridium CMS

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:

  • namestring | string[]
    An allowed list of element, molecule, or ion names.
  • depthnumber
    The default depth of the relationship to populate in the API. Defaults to Infinity.
  • displayNamestring
    The display name of the field. Defaults to the name of the property.
  • requiredboolean
    Whether the field is required. Defaults to false.
  • layoutLAYOUT
    The layout of the field in the admin. Defaults to LAYOUT.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:

  • namesstring[]
    An allowed list of element, molecule, or ion names.
  • depthnumber
    The default depth of the relationship to populate in the API. Defaults to Infinity.
  • minnumber
    The minimum number of relationships. Defaults to 0.
  • maxnumber
    The maximum number of relationships. Defaults to Infinity.
  • isRepeatableboolean
    Allows multiple of the same relationship to be created. Defaults to true.
  • displayNamestring
    The display name of the field. Defaults to the name of the property.
  • requiredboolean
    Whether the field is required. Defaults to false.
  • layoutLAYOUT
    The layout of the field in the admin. Defaults to LAYOUT.full.