Appwrite icon

Appwrite

Interact with Appwrite API

Actions181

Attribute → Create Enum

AI-generated

Overview

This node operation creates an Enum attribute in a specified Appwrite database collection. It allows users to define an attribute with a key, specify if it is required, set a default value, and determine if the attribute is an array. The Enum elements are provided as a comma-separated string. This operation is useful for defining constrained sets of string values for attributes in Appwrite collections, such as status fields, categories, or predefined options.

Use Case Examples

  1. Creating an Enum attribute 'status' with elements 'pending,approved,rejected' in a collection to manage workflow states.
  2. Defining a 'priority' Enum attribute with elements 'low,medium,high' to categorize tasks.

Properties

Name Meaning
Database ID The ID of the Appwrite database where the collection resides.
Collection ID The ID of the collection within the database where the Enum attribute will be created.
Attribute Key The key (name) of the attribute to create.
Required Indicates whether the attribute is mandatory.
Default Value The default value assigned to the attribute if none is provided.
Array Specifies if the attribute is an array of values rather than a single value.
Elements Comma-separated string listing the possible values for the Enum attribute.

Output

JSON

  • attributeId - The unique identifier of the created Enum attribute.
  • key - The key (name) of the created attribute.
  • type - The type of the attribute, which is 'enum' in this operation.
  • elements - The list of possible values for the Enum attribute.
  • required - Indicates if the attribute is required.
  • defaultValue - The default value of the attribute if set.
  • array - Indicates if the attribute is an array.

Dependencies

  • Appwrite API key credential for authentication and access to the Appwrite project and database.

Troubleshooting

  • Ensure the provided Database ID and Collection ID are correct and exist in the Appwrite project.
  • Verify that the API key credential has sufficient permissions to create attributes in the specified database and collection.
  • Check that the 'Elements' string is properly formatted as a comma-separated list without trailing commas or invalid characters.
  • If the node throws an 'Unknown resource' error, confirm that the resource parameter is set to 'attribute' and the operation to 'createEnum'.
  • If the operation fails, review the error message for details such as missing required parameters or network issues.

Links

Discussion