About Collection Fields

Collection fields define the structure and data types of collections. They act as the columns in your collection, determining what kind of information each data item can store and how it's organized.

You can manage fields using the Data API or through the CMS.

Field IDs

Every field has a unique field ID that serves as its identifier when you reference it in code.

For example, here title, price, and available are field IDs in the Listings collection:

Copy

Learn how to find a field ID.

Field types

The CMS supports various field types to handle different kinds of data.

The available field types include:

  • Essentials: Basic data types like text, numbers, dates, and booleans.
  • Media: Types for images, audio, video, and files.
  • Time and location: Types for storing time zones, locations, and addresses.
  • JavaScript: Types for storing objects and arrays.

Field types can provide structure and validation but aren't strictly enforced. You can technically store data that doesn't match the field type, though this isn't recommended.

Reference fields

Reference fields create connections between different collections. They store the ID of an item from another collection, allowing you to link related data together.

You can use single reference fields to connect to a single item, or multi-reference fields to connect to multiple items from another collection.

System fields

System fields are automatically created in every collection to store essential metadata.

  • _id: Unique identifier for each item.
  • _createdDate: Timestamp when the item was first created.
  • _updatedDate: Timestamp when the item was last modified.
  • _owner: ID of the visitor or member who created the item.

System fields are read-only and managed automatically by the CMS. However, you can explicitly set a unique _id of your choice when inserting or saving new items using the Data API.

Undefined fields

Undefined fields are those that appear in your collection but aren't part of the defined structure. This can happen when restoring a previous version of a site or when adding data using the Data API that doesn't match a defined collection field.

Undefined fields allow flexibility when working with evolving data structures, but it's best practice to define all fields properly in your collection.

See also

Did this help?