Directus (flagbit) icon

Directus (flagbit)

Consume Directus API

Relation → Create

AI-generated

Overview

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

  1. Creating a relation to link the 'featured_image' field in the 'articles' collection to the 'directus_files' collection.
  2. 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

Discussion