Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Directus (DrWade) node for n8n allows you to interact with the Directus API. Specifically, when using the Relations resource and the Delete operation, this node enables you to delete a relation between collections in your Directus project. This is useful for managing and cleaning up relationships (such as foreign key constraints or many-to-many links) between tables/collections in your data model.

Common scenarios:

  • Removing an obsolete or incorrect relationship between two collections.
  • Cleaning up database schema by deleting unnecessary relational fields.
  • Automating schema management tasks as part of a CI/CD pipeline for your Directus instance.

Example use case:
You have a books collection with a relation field author. If you want to remove this relation (e.g., because you're restructuring your data model), you can use this node to delete the relation directly from your workflow.


Properties

Name Type Meaning
Collection options Unique name of the parent collection. This is the collection where the relation is defined.
Field options Name of the field that holds the related primary key. This matches the column name in the DB.

Output

  • The output will be a JSON object representing the result of the delete operation.
  • On success, the response is typically an empty object {} or a confirmation structure, depending on the Directus API version and configuration.
  • On failure, if "Continue On Fail" is enabled, the output will contain an error message in the form:
    { "error": "Error message here" }
    

Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials (directusApi) configured in n8n.
  • n8n Configuration: No special environment variables are needed beyond standard credential setup.

Troubleshooting

Common issues:

  • Invalid Collection or Field: If the specified collection or field does not exist, the API will return an error.
  • Insufficient Permissions: The API user must have permission to modify schema/relations.
  • Relation In Use: Attempting to delete a relation that is required elsewhere may fail.

Typical error messages:

  • "Collection not found": Check the spelling and existence of the collection.
  • "Field not found": Ensure the field name matches exactly as in Directus.
  • "Unauthorized": Verify your API credentials and permissions.
  • "Cannot delete relation": The relation might be referenced elsewhere; check dependencies before deletion.

Links and References


Discussion