Index
Edit

Object

The object type is the bread and butter of your data model. You use it to define custom types that has fields of strings, numbers, arrays as well as other object types.

Example

Say you want to add director as a field on movie, and director needs its own fields, so we make it an object. It usually makes sense to define types separately, thus making them reusable from other types.

{
  title: 'Movie',
  name: 'movie',
  type: 'object',
  fields: [
    {
      title: 'Director',
      name: 'director',
      type: 'director'
    },
    // ... title and other fields on movie
  ]
},
{
  title: 'Director',
  name: 'director',
  type: 'object',
  fields: [
    {
      title: 'Name of Director',
      name: 'name',
      type: 'string'
    },
      {
      title: 'Any good?',
      name: 'anyGood',
      type: 'boolean'
    }
  ]
}

Example output data

{
  "_type": "director",
  "_id": "2106a34f-315f-44bc-929b-bf8e9a3eba0d",
  "name": "Stanley Kubrick",
  "anyGood": true
}

A movie with this director will be stored like this:

{
  "_type": "movie",
  "director": {
    "_type": "reference",
    "_ref": "2106a34f-315f-44bc-929b-bf8e9a3eba0d"
  },
  "title": "Dr. Strangelove"
  //...
}

Previous: Schema TypesNext: String