Actions118
- Item Actions
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revision Actions
- Role Actions
- Server Actions
- Setting Actions
- User Actions
- Utility Actions
- Webhook Actions
Relation → Create
AI-generatedOverview
This node creates a new relation in the Directus system. It is useful for defining relationships between collections, such as linking a field in one collection to another collection, enabling relational data structures within Directus. For example, you can create a relation between an 'articles' collection and a 'directus_files' collection to associate featured images with articles.
Use Case Examples
- Creating a relation to link the 'featured_image' field in the 'articles' collection to the 'directus_files' collection.
- Defining a new relation to establish a many-to-one relationship between two collections.
Properties
| Name | Meaning |
|---|---|
| Data (JSON) | A partial relation object in JSON format that specifies the details of the relation to be created, such as the source collection, field, and related collection. |
Output
JSON
id- The unique identifier of the created relation.collection- The source collection of the relation.field- The field in the source collection that holds the relation.related_collection- The target collection that the relation points to.type- The type of the relation (e.g., one-to-many, many-to-one).meta- Additional metadata about the relation.
Dependencies
- Requires an API key credential or authentication token for Directus API access.
Troubleshooting
- Ensure the JSON data provided is correctly formatted and includes all required fields for the relation object.
- Verify that the specified collections and fields exist in the Directus instance before creating the relation.
- Check API authentication credentials if the node fails to connect or returns authorization errors.
Links
- Directus Relation Object Documentation - Official documentation describing the relation object structure and usage in Directus API.