Actions109
- Activity Actions
- Assets Actions
- Authentication Actions
- Collections Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
- Webhooks Actions
Overview
This node integrates with the Directus API to manage relations between collections in a Directus-managed database. Specifically, the "Relations" resource with the "Get" operation allows users to retrieve metadata about how collections relate to each other via relational fields.
Typical use cases include:
- Fetching relation details for a specific collection and field to understand foreign key relationships.
- Automating workflows that depend on relational data structures within Directus.
- Dynamically loading relational metadata to configure further data processing or UI elements.
For example, you might use this node to get the relation information of the "author" field in the "books" collection to know which primary key it references.
Properties
| Name | Meaning |
|---|---|
| Collection | Unique name of the parent collection from which to get relation information (e.g., "books"). |
| Field | Name of the field holding the related primary key; corresponds to the column name in the DB. |
Output
The output is a JSON object containing the relation metadata for the specified collection and field. This typically includes details such as the related collection, the type of relation, and any constraints or keys involved.
Example output structure (simplified):
{
"id": "relation_id",
"collection": "books",
"field": "author",
"related_collection": "authors",
"junction_field": null,
"one_field": "author",
"many_field": "books",
"type": "one-to-many",
"meta": { ... }
}
No binary data output is produced by this operation.
Dependencies
- Requires an active connection to a Directus instance via an API key credential.
- The node uses the Directus REST API endpoints under
/relations. - No additional external dependencies beyond the Directus API and configured credentials.
Troubleshooting
Common issues:
- Invalid or missing collection or field names will cause errors.
- Network connectivity problems or incorrect API credentials will prevent successful API calls.
- If the specified relation does not exist, the API may return a 404 error.
Error messages:
"Relation not found": Check that the collection and field names are correct and that the relation exists."Unauthorized"or authentication errors: Verify that the API key credential is valid and has sufficient permissions.- JSON parsing errors: Ensure that input parameters are correctly formatted and no invalid JSON is provided.
Resolution tips:
- Use the "Collection" dropdown to select valid collections loaded dynamically.
- Use the "Field" dropdown, which depends on the selected collection, to pick valid relational fields.
- Confirm API credentials and network access to the Directus instance.