Index
Edit

Reference

Relations between documents are modeled using the reference type. To model a one-to-many relation, store the references in an array.

Properties

typestring

Required. Value must be set to reference.

toarray

Required. Must contain an array naming all the types which may be referenced e.g. [{type: 'person'}]. See more examples below.

weakboolean

If set to true the reference will be made weak. This means you can discard the object being referred to without first deleting the reference, thereby leaving a dangling pointer.

titlestring

Human readable label for the field.

namestring

Required. The field name. This will be the key in the data record.

hiddenboolean

If set to true, this field will be hidden in the Content Studio.

readOnlyboolean

If set to true, this field will not be editable in the content studio.

descriptionstring

Short description to editors how the field is to be used.

Example: Basic reference

Define the movie's director as a reference to a person:

Schema
{
  name: 'movie',
  type: 'object',
  fields: [
    {
      title: 'Director',
      name: 'director',
      type: 'reference',
      to: [{type: 'person'}]
    }
  ]
}
JSON output
{
  "_type": "reference",
  "_ref": "ffda9bed-b959-4100-abeb-9f1e241e9445" /* This could be the id of Jessica Chastain */
}

Example: Allow reference to more than one type

The directors field is an array which can contain both person and bovinae (in the rare occasion a cow would direct a movie) references:

Schema
{
  title: 'Directors',
  name: 'directors',
  type: 'array',
  of: [
    {
      type: 'reference',
      to: [
        {type: 'person'},
        {type: 'bovinae'}
      ]
    }
  ]
}
JSON output
[
  {
    "_type": "reference",
    "_ref": "9b711031-3744-47ab-9bb7-1bceb177d0d0" /* this could be the id of a Yvonne, the escaped cow */
  },
  {
    "_type": "reference",
    "_ref": "ffda9bed-b959-4100-abeb-9f1e241e9445" /* this could be the id of Matt Damon */
  }
]

Previous: DateNext: Geopoint