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.
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:
Learn how to find a field ID.
The CMS supports various field types to handle different kinds of data.
The available field types include:
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 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 are automatically created in every collection to store essential metadata.
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 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.