Documentation Index
Fetch the complete documentation index at: https://mintlify.com/directus/directus/llms.txt
Use this file to discover all available pages before exploring further.
What are Fields?
Fields are individual pieces of content within a collection, representing the columns in your database table. Each field has a specific data type and configuration that determines what kind of information it can store and how it’s displayed in the Directus app.Every field in Directus has both a schema (the database column definition) and meta (the app interface configuration).
Field Structure
A field consists of three main components:Field Schema
The schema defines the database column properties:data_type- SQL data typemax_length- Maximum length for stringsis_nullable- Whether NULL values are allowedis_primary_key- Primary key designationhas_auto_increment- Auto-increment for integersis_unique- Unique constraintis_indexed- Database indexdefault_value- Default value for new itemsnumeric_precision- Precision for decimal numbersnumeric_scale- Scale for decimal numbers
Field Meta
The meta defines how the field appears in the app:Field Types
Directus supports a comprehensive set of field types that map to database column types:Scalar Types
| Type | Database Type | Description |
|---|---|---|
string | VARCHAR | Text with max length |
text | TEXT | Long text content |
integer | INTEGER | Whole numbers |
bigInteger | BIGINT | Large whole numbers |
float | FLOAT | Decimal numbers |
decimal | DECIMAL | Precise decimal numbers |
boolean | BOOLEAN | True/false values |
date | DATE | Date without time |
time | TIME | Time without date |
dateTime | DATETIME | Date and time (no timezone) |
timestamp | TIMESTAMP | Date and time (with timezone) |
json | JSON | Structured JSON data |
uuid | UUID | Universally unique identifier |
hash | VARCHAR(255) | Hashed strings (passwords) |
csv | TEXT | Comma-separated values |
Geometry Types
Support for spatial data:geometrygeometry.Pointgeometry.LineStringgeometry.Polygongeometry.MultiPointgeometry.MultiLineStringgeometry.MultiPolygon
Alias Types
Alias fields don’t exist in the database but provide virtual functionality:alias- No database column, UI onlyo2m- One-to-Many relationship (virtual)m2m- Many-to-Many relationship (virtual)m2a- Many-to-Any relationship (virtual)files- File relationshipstranslations- Translation interface
Alias fields are marked with
alias: true in the schema and don’t create database columns. They’re used for relationships and computed values.Creating Fields
Fields can be created through the API:~/workspace/source/api/src/services/fields.ts:359-431), creating a field:
- Validates the field doesn’t already exist
- Adds database-specific flags for type handling
- Creates or alters the database table
- Saves metadata to
directus_fields - Automatically assigns a sort order
Field Interfaces
Interfaces determine how fields are displayed and edited in the app:Common Interfaces
- input - Simple text input
- textarea - Multi-line text
- wysiwyg - Rich text editor
- markdown - Markdown editor
- dropdown - Select from predefined options
- checkboxes - Multiple choice selection
- toggle - Boolean switch
- slider - Numeric slider
- datetime - Date/time picker
- file-image - Image upload
- select-dropdown-m2o - Many-to-One relationship selector
- list-o2m - One-to-Many relationship list
Interface Options
Each interface has specific options:Field Displays
Displays control how field values appear in item listings:- formatted-value - Formatted number/date
- boolean - Checkmark/X icon
- color - Color swatch
- datetime - Formatted date/time
- image - Thumbnail image
- labels - Colored labels
- rating - Star rating
- related-values - Display related item fields
Field Validation
Validation rules ensure data integrity using filter syntax:System Fields
Directus automatically includes system fields in collections:id- Primary key (auto-generated)user_created- User who created the itemuser_updated- User who last updated the itemdate_created- Creation timestampdate_updated- Last update timestamp
~/workspace/source/api/src/controllers/fields.ts:138-144):
Conditional Fields
Fields can be shown/hidden based on conditions:Field Groups
Organize related fields into collapsible groups:Updating Fields
Update field schema or metadata:Deleting Fields
Deleting a field removes both the database column and metadata:~/workspace/source/api/src/services/fields.ts:697-903), deleting a field:
- Removes related foreign key constraints and relationships
- Drops the database column
- Deletes metadata from
directus_fields - Updates permissions to remove field references
- Cleans up collection metadata references
Common Use Cases
Rich Content
Use WYSIWYG or Markdown fields for article bodies, product descriptions, and formatted text content.
Media Management
File and image fields with transformation options for galleries, featured images, and document attachments.
Relational Data
M2O, O2M, and M2M fields to create relationships between collections like authors, categories, and tags.
JSON Data
JSON fields for flexible, schema-less data like product options, metadata, or API responses.
Best Practices
Related Concepts
- Collections - Containers that organize fields
- Items - Records that contain field values
- Relationships - Connect fields across collections