Creating Collection Attributes
In Appwrite Cloud, database collection attributes serve a critical role in defining the structure (schema) of the documents that are stored in a collection
Function of Collection Attributes in Appwrite Cloud
Collection attributes:
-
Define the schema (data model) of a collection.
-
Ensure data consistency by specifying what kind of data each field in a document should contain.
-
Provide validation, type enforcement, and optional default values for fields.
Attribute Types Available in Appwrite
string, integer, float, boolean, email, enum, url, ip, array, object, datetime
Must to Know
You have to create separate attributes for each collection.
1- user_profiles collection attributes
user_profiles Attributes :
- userId (string)
- name (string)
- user_email (string)
- picture (string)
- current_active_plan (string)
- is_active (boolean)
- char_allowed (integer)
- char_remaining* (integer)
- current_plan_start_date (datetime)
- current_plan_expiry_date (datetime)
- active_product_id (string)
- billing_cycle (string)
- plan_type (string)
- is_admin (boolean)
- creem_customer_id (string)
- creem_subscription_id (string)
- voice_clone_allowed (integer)
- voice_clone_used (integer)
2- user_models collection attributes
user_profiles Attributes :
- userId (string)
- fishAudioModelId (string)
- title (string)
- state (string)
- createdAt (string)
- coverImage (boolean)
3- browse_models collection attributes
user_profiles Attributes :
- title (string)
- image_url (string)
- fish_model_id (string)
- model_audio_url (string)
4- history collection attributes
user_profiles Attributes :
- userId (string)
- created_at (string)
- audio_url (string)
5- subscriptions collection attributes
user_profiles Attributes :
- user_id (string)
- created_at (string)
- current_period_start_date (string)
- current_period_end_date (string)
- plan_name (string)
- billing_cycle (string)
- status (string)
Case Sensitivity in Attribute Names
When working with the Appwrite Cloud database collections, attribute names are case-sensitive. This means that attributes like UserName, username, and USERNAME are treated as completely different fields.