Field Types

Learn about available field types for your models.

Default

Every type is pre-defined with created and modified timestamp fields. These are automatically managed.

Primitive

string

Maximum length: 100 UTF-8 characters. May be marked as unique: true.
Provisioned size: 400 bytes (4 bytes provisioned per character).

boolean

true/false boolean value.
Provisioned size: 1 byte.

integer

Non-floating 64 bit integer (long).
Provisioned size: 8 bytes.

double

Floating-point number (64-bit double precision, IEEE 754).
Provisioned size: 8 bytes.

Options

options are a special purpose string field, limited to pre-configured string values. The options / values must be camel case (example, exampleOne, exampleTwoOther), using single byte letters.
Provisioned size: 50 bytes.

Example Definition


status:
  type: options
  init: false
  values:
    - pending
    - disabled
    - active
    

Initialization

To use the first listed value as a default / pre-initialized value for newly created models, simply change init to true. Otherwise it will default to null.

Type-Safe Access

Instead of referencing the available values by string, it's recommend to use the type-safe version. Given a Product model:


let p = new Product().status(Product.status.pending);
    

Speciality

Speciality fields provide validation, and often lower provisioned sizes.

country

ISO 3166-1 alpha-3 country code.
Provisioned size: 3 bytes.

map

Special case field that should be used sparingly. Maps support free-form string, number, and boolean values. Maps are not indexed, and not queryable. They are only suitable for free-form fields that may vary widely for the same model type.

Images

The image field type stores a single image. Supported image types are JPG, GIF, PNG. For more information on uploading and displaying images, see Models / Images.

Maximum Size

Upload sizes of up to 10MB are accepted. However images that exceed 2000px wide will be proportionally re-sized to 2000px wide with a variable height. The size of an image does not contribute to the size of a model.

Example Definition


coverImage: image
    

Rich Text / HTML

text

Limited and validated HTML "rich text".
Supports a series of blocks h1-h6, p, pre, section, ul/li, ol/li. section must contain h1-h6 as its first child.
Within each block, the following inline elements are supported: a, br, code, em, s, strong, sub, sup.
Provisioned and maximum size is 10,000 bytes for the Content Type, and 1,000 bytes for all other types.

title

Special kind of text which is limited to a single h1-h6 block containing allowed inline elements.
Maximum length: 100 UTF-8 characters. Provisioned size: 400 bytes (4 bytes provisioned per character).

Embedded

This is the field type corresponding to a complex value defined by an Embedded model type.

It may be a many valued array/list, in which case there is a limit of 20 embedded entries.

Provisioned size: sum of provisioned field sizes * times number of possible entries.

For more information on defining an embedded field, click here.

Unique Values

The String field type may be marked as unique for the Universal model type only. Unique values are constrained/scoped to the nearest container.

Deleting/removing a document will delete all associated unique values.

Warning: Commits will fail / throw an exception if there is a unique value violation. Therefore it's highly recommended that if a unique value is being created or changing, that there exists logic to check whether the unique value is available.

URL Identifiers

uid is used for "user friendly" unique identifiers destined for URL paths (aka URL slugs).

This field is always unique, and is available for the Universal and Content type's.

To keep URLs formatted according to best practices, it must start and end with any character a-z, A-Z, or 0-9. Between the start and end, dash characters are also allowed. Minimum length is 2 characters. Maximum length is 100 characters.

Note: UID's behave differently than other unique values. Because they are destined for URLs, it's implied that when modified the previous value is not lost (otherwise any previously published URL would result in a broken link). Therefore a single model field may have multiple unique UID values associated with it, however at any given time only one is "current" or "primary".

In an ideal scenario from an SEO standpoint, if the visitor has reached a URL by an older UID, then it's recommended you redirect to the current/primary UID value.

Provisioned size: 100 bytes.