Directus (flagbit) icon

Directus (flagbit)

Consume Directus API

Overview

This node is designed to update a field within a specified collection in a Directus data source. It allows users to modify the metadata, schema, and type of an existing field by specifying the collection and the unique field name. This operation is useful when you need to change the structure or properties of fields in your Directus collections without manually editing them through the Directus interface.

Common scenarios include:

  • Updating the data type of a field to better reflect the stored data.
  • Modifying the JSON schema or meta information associated with a field.
  • Adjusting relationships or file associations for fields in content collections.

For example, you might use this node to change a field's type from "string" to "integer" or to add additional metadata that affects how the field behaves in your application.

Properties

Name Meaning
Collection The name of the collection where the field exists. This identifies which collection's field will be updated.
Field Name The unique name of the field within the collection to update.
JSON/RAW Parameters A boolean flag indicating whether the body parameters should be provided as raw JSON or via the UI key-value pairs.
Body Parameters When JSON/RAW Parameters is true, this is the JSON object containing the body parameters for the update request.
Update Fields When JSON/RAW Parameters is false, this collection allows setting individual update options:
- Meta (JSON) JSON object representing meta information about the field.
- Schema (JSON) JSON object representing the schema details of the field.
- Type The Directus-specific data type to cast the field value. Options include: Big Integer, Boolean, CSV (array of strings), Date, DateTime, Decimal, Field Group, Float, Hash, Integer, JSON, various relationship types (M2A, M2M, M2O, O2M), Multiple Files, Presentation, Single File, String, Text, Time, Timestamp, UUID.

Output

The node outputs JSON data representing the result of the update operation on the field. This typically includes confirmation of the updated field properties or any error messages if the update failed.

If the node supports binary data output, it would relate to file-type fields, but based on the provided properties, the primary output is JSON describing the updated field state.

Dependencies

  • Requires access to a Directus API endpoint configured with appropriate authentication credentials (e.g., an API key or token).
  • The node depends on n8n's internal methods for loading options dynamically for collections and fields.
  • No external libraries beyond those bundled with the node are explicitly required.

Troubleshooting

  • Invalid Field or Collection Names: Errors may occur if the specified collection or field name does not exist. Verify names are correct and available in the Directus instance.
  • Incorrect JSON Format: When using JSON/RAW parameters, ensure the JSON is well-formed; otherwise, the request will fail.
  • Permission Issues: The API credentials used must have sufficient permissions to update fields in the target collection.
  • Unsupported Data Types: Selecting an unsupported or incorrect data type may cause errors or unexpected behavior.
  • API Connectivity: Network issues or incorrect API endpoint configuration can prevent successful updates.

Links and References

Discussion