Actions100
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Item Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Directus - Relation: Update operation allows you to update the configuration of a relation between collections in a Directus project. This is useful when you need to modify how two collections are related, such as changing the metadata or settings of a relational field (e.g., updating a foreign key relationship, adjusting cascade rules, or modifying display options).
Common scenarios:
- Adjusting the properties of an existing relation after changes in your data model.
- Updating relation metadata to reflect new business logic.
- Automating schema updates as part of a deployment or migration workflow.
Practical example:
Suppose you have a books
collection with an author
field relating to an authors
collection. If you want to change the relation's metadata (such as labels, visibility, or constraints), you can use this node to update those settings programmatically.
Properties
Name | Type | Meaning |
---|---|---|
Collection | options | Unique name of the parent collection. Specifies which collection the relation belongs to. |
Field | options | Name of the field that holds the related primary key. Matches the column name in the database. |
Data (JSON) | json | A partial relation object. Contains the properties to update for the relation. |
Output
- The output will be a single object in the
json
field representing the updated relation. - The structure of the output matches the Directus relation object, and may include fields such as:
collection
field
related_collection
meta
(with subfields depending on what was updated)- Other relation-specific properties
Example output:
{
"collection": "books",
"field": "author",
"related_collection": "authors",
"meta": {
"one_field": "articles"
}
}
Dependencies
- Directus API: Requires access to a running Directus instance.
- API Credentials: You must configure the
directusApi
credentials in n8n for authentication.
Troubleshooting
Common issues:
- Invalid Collection or Field: If the specified collection or field does not exist, the node will throw an error.
- Malformed JSON in Data: If the
Data (JSON)
property contains invalid JSON, the request will fail. - Insufficient Permissions: The API user must have permission to update relations; otherwise, you'll receive an authorization error.
Error messages and resolutions:
"Cannot find collection/field"
: Double-check the spelling and existence of the collection and field."Unexpected token ... in JSON"
: Ensure theData (JSON)
input is valid JSON."403 Forbidden"
or"401 Unauthorized"
: Verify your API credentials and permissions.