Model Definition

Learn about defining model and field types.

To define and use data models in your project, create a directory named "πŸ“¦" in the root of your project. This directory will contain .yaml files that define the model names and fields, as well as the structure of parent/child (container) relationships.

Model Name and Type

The file name indicates both the name of the model as well as the model's type. The model's type is denoted with a specific emoji prefix.

Within the directory "πŸ“¦", and given a file name named 🌐Article.yaml, a "Universal" model named Article will be available to your scripts.


To define models that are in a container, place them into directories. Example files and folders in the "πŸ“¦" directory which define 3 model types, two of which are in containers.



Field names must follow "camel case" conventions, e.g. "camel" or "camelCase". All defined fields are indexed and required by default. Field definitions have a short form and long form, which can be mixed and matched as needed in the same file. Note: .yaml files use spaces, not tabs, for indentation.

Short Form

To compactly use all defaults for a field, simply assign a field type immediately following your field name.

fieldName: string
otherField: boolean
somethingEmbed: EmbeddedModelName

Long Form

To define additional field properties use the long form. In the long form you only need to define the properties you're interested in.

  type: string
  optional: true
  unique: true

  type: boolean

Embedded Values


Global embedded model types have a distinct name and configuration file, and may be referenced in a configuration file like any other field type.


Local embedded model types are defined directly in the model that uses them.

    price: double


Before using embedded lists, review the query limitations and suggestions.

Whether defined globally or locally, embedded values can allow multiple values (up to 20 entries) by adding "[]" after the field name:

    price: double

If requirements don't call for the maximum of 20 entries, then provision less entries by specifying a number (less than 20) between the brackets.

address[5]: Address

Capped/Rolling Lists

Lists of embedded values may also be used to retain only N recent values, where N is the maximum size defined for the embedded list.

This works in a way similar to circular buffers: once a list fills its allocated space, it makes room for new embedded entries by overwriting the oldest value in the list.

Use the put method on the list to achieve this behavior. Assuming an embedded value list with a maximum number of entries set to 2:

let p = new Post();
p.recentComments.put(new Post.Comment().content('<p>a</p>'));
p.recentComments.put(new Post.Comment().content('<p>b</p>'));
p.recentComments.put(new Post.Comment().content('<p>c</p>'));

The Post will now only contain comments b and c. Putting the last comment c dropped off the older comment a, since that exceeded the maximum of 2 entries for this embedded list field.