Fields

Small descriptions of all supported field types

What are Fields?

Fields are used to describe the individual attributes of a model. Think of them as Columns in a spread sheet. Each column would represent one type of data (Field), and every row would represent one whole entry (Record).

Default Values

Fields have a property called default value. This is used in the response of the query records API request. If a field value is empty, then the default value will be returned instead. This behaviour is on by default but can be disabled in the API by using query parameter loadDefaults=false.

Code Name

Fields have two names. One is for displaying the field in the Fuchsia UI, and one is the codeName. The codeName is used for the API JSON responses, and can not include any spaces.

Field Types

Fields can be one of many different types. Every type is unique in the way it stored or handles data. Here are all the supported field types:

Short Text

Used for simple fields that are usually less than 50 characters long, such as name of a Person, a title of a Movie, a street name for an Address

Rich Text

Used for longer form fields that require a lot of space and formatting. Good use cases for Rich Text would be for the body of an Article, the extensive review of a Movie, or a description of a House for sale.

Markdown

Markdown is a simple language for authoring long form articles or descriptions with basic formatting. Fuchsia's API can automatically render markdown to HTML if the query parameter convertMarkdown=true is added to the records query API request.

HTML

Raw HTML can be used for more advanced formatting and styling of content. For HTML that can have other fields dynamically injected, check out the Template type.

JSON

JavaScript Object Notation (JSON) can also be used for storing raw data. This data cannot be queried with Fuchsia's API querying, but can still be useful for bulk storage of unstructured data.

Number

Number types can either be floating point numbers or regular integers.

Boolean

Boolean's are usually used for checkboxes or yes/no style fields. The value will always either be true, false or null.

Media

Media assets are used for storing files, images, videos or anything else you would normally store in a computer folder.

Color

A hexadecimal representation of a color. Example: #ffffff for white.

Date

Dates are a string of text in 2006-01-02T15:04:05Z07:00This format is known as RFC3339 and is ISO8601 compliant.

Time

Time is a simple string of text in the format of hh:mm:ss

Location

Used for storing longitude and latitude of physical places on earth. It is in the format of:

// Location of Montreal, QC, Canada
{
lat: 45.5017, // latitude
lng: 73.5673 // longitude
}

Choice

A choice type means that only a certain amount of pre-approved short strings can be used as the value. Setup the choices in the Model, then any record with a Choice type will only be able to choose from that list of options.

Reference

A reference is a special type, it allows loading and referencing other records from the same or different collections, of any model. The API will return the fully loaded reference when the query parameter loadReferences=true is used.

Template

Templates are used for dynamically generating HTML that has dynamic records injected into it at execution time. Templates directly use the Golang Template Language and have records injected by using the query parameter include[<record ID>]=<Name of Variable>.

For example: if we have a template that requires a variable called Person to be injected, then the template would access this record like:

<h1>Hello {{ .Person.Name }}</h1>

This assumes that you have a Model of a Person that has a field called Name.

Check out the API docs for details on how these field types are used.