The Anatomy of a Schema

Brightlever: A Modern Lightweight Headless CMS for your Enterprise Data.

Basic Structure

Content Type schemas are stored as a JSON document consisting of the schema's id, name and properties.

id: Is the envrionmentally unique string identifier that will be used to access the documents associated with this schema's property definition. It cannot be chance once the schema is saved.

name: Is the name used within the Brightlever UI to represent documents of content type.

description: A description of what the schema properties are describing.

properties: Is an array of properties that define the actual schema properties.

Example:

{
  "name": "widget",
  "id": "widget",
  "properties": [
    {
      "listView": true,
      "localized": true,
      "type": "text",
      "title": "Name",
      "useEnum": false,
      "key": "name",
      "labelView": true,
      "required": true
    },
    {
      "listView": false,
      "localized": false,
      "type": "html",
      "title": "Description",
      "useEnum": false,
      "labelView": false,
      "required": false,
      "key": "description"
    },
    {
      "listView": false,
      "localized": false,
      "type": "file",
      "title": "Image",
      "useEnum": false,
      "labelView": false,
      "required": false,
      "key": "image"
    }
  ]
}

Property Attributes

listView: This denotes if the property should be include in the default list view UI.

localized: This denotes if the property should be localized.
If true, the property will be saved as an object with a key per localized property value.

{
    "jobTitle": {
        "en": "bureaucrat",
        "es": "burócrata",
        "ru": "бюрократ"
    }
}

title: Denote the how the Brighllever UI should refer to the property.

key: Denotes the value that the property should be refered to via programmatic apis.

description: A description of the purpose of the property.

type: Denotes the data type that is expected as the property value.

useEnum: Denotes if the property should have a predefined set of values (string and number only).

labelView: Denotes if the property should be used when create labels for content type instances.

required: Denotes if the propery requires a value if the documents is to be considered valid.

enum: For use with properties that have useEnum set to true.

example:

    ...,
    {
        "type": "text",
        "useEnum": true,
        "enum": [
            "Rickenbacker",
            "Gretsch"
        ],
        "listView": false,
        "labelView": false,
        "required": false,
        "localized": false,
        "title": "Guitar Type",
        "key": "guitarType"
    },
    ...

items: For use with properties with the type set to "array". It defines what is expected to populated the array.

example:

    ...,
    {
      "type": "array",
      "items": {
        "type": "text",
        "useEnum": false
      },
      "useEnum": false,
      "listView": false,
      "labelView": false,
      "required": false,
      "localized": false,
      "title": "Options",
      "itemTitle": "option",
      "key": "options"
    },
    ...

itemTitle: Used with properties with the type of array to denote how to refer to items within the resulting array.

properties: Use with properties with teh type of object to denote what properties should be expected.

example:

    ...,
    {
        "title": "My Object",
        "key": "myObject"
        "type": "object"
        "properties": [
            {
                "listView": true,
                "localized": true,
                "type": "text",
                "title": "Name",
                "useEnum": false,
                "key": "name",
                "labelView": true,
                "required": true
            },
            {
                "listView": false,
                "localized": false,
                "type": "html",
                "title": "Description",
                "useEnum": false,
                "labelView": false,
                "required": false,
                "key": "description"
            }
        ]
    },
    ...

Property Types

text

longtext

html

markdown

number

boolean

object

array

tel

date

datetime

email

time

password

color

file

url

has-one

has-many

tags