Actions100
- 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
Overview
The Fields → List operation in this custom n8n node for Directus allows you to retrieve a list of all fields (columns) defined within a specific collection in your Directus instance. This is useful for dynamically discovering the schema of a collection, automating documentation, or building workflows that need to adapt to changes in the data model.
Common scenarios:
- Generating dynamic forms or UI elements based on collection fields.
- Validating or mapping data before inserting/updating items in a collection.
- Auditing or documenting the structure of collections.
Practical example:
Suppose you have a collection called articles
and want to fetch all its fields to build a dynamic import workflow or to display available columns to users.
Properties
Name | Type | Meaning |
---|---|---|
Collection | options | The name of the collection whose fields you want to list. Required. |
Split Into Items | boolean | If enabled, outputs each field as a separate item; otherwise, returns an array of fields in a single item. |
Output
- If Split Into Items is
false
:- The output will be a single item with a
json
property containing an array of field objects, each representing a field in the specified collection.
- The output will be a single item with a
- If Split Into Items is
true
:- Each field will be output as a separate item, with the
json
property containing the field object.
- Each field will be output as a separate item, with the
Example output when "Split Into Items" is false:
{
"json": [
{
"field": "id",
"type": "integer",
// ...other field properties
},
{
"field": "title",
"type": "string"
// ...other field properties
}
// ...
]
}
Example output when "Split Into Items" is true:
{
"json": {
"field": "id",
"type": "integer"
// ...other field properties
}
}
// Next item:
{
"json": {
"field": "title",
"type": "string"
// ...other field properties
}
}
Note: The exact structure of each field object depends on your Directus instance's schema.
Dependencies
- Directus API: Requires access to a running Directus instance.
- API Credentials: You must configure the
directusApi
credentials in n8n for authentication.
Troubleshooting
- Invalid Collection Name: If the specified collection does not exist, the node will throw an error. Double-check the collection name.
- Authentication Errors: If credentials are missing or invalid, you'll receive an authentication/authorization error from Directus.
- Empty Output: If the collection has no fields, the output will be an empty array or no items (depending on "Split Into Items").
- Error Handling: If an error occurs and "Continue On Fail" is enabled, the output will contain an
error
property with the error message.