Collections

Appwrite uses collections as containers of documents. Each collection contains many documents identical in structure. The terms collections and documents are used because the Appwrite JSON REST API resembles the API of a traditional NoSQL database.

That said, Appwrite is designed to support both SQL and NoSQL database adapters like MariaDB, MySQL, or MongoDB in future versions.

Create collection

You can create collections using the Appwrite Console, a Server SDK, or using the CLI.

    Permissions

    Appwrite uses permissions to control data access. For security, only users that are granted permissions can access a resource. This helps prevent accidental data leaks by forcing you to make more concious decisions around permissions.

    By default, Appwrite doesn't grant permissions to any users when a new collection is created. This means users can't create new documents or read, update, and delete existing documents.

    Learn about configuring permissions.

    Attributes

    All documents in a collection follow the same structure. Attributes are used to define the structure of your documents and help the Appwrite's API validate your users' input. Add your first attribute by clicking the Add attribute button.

    You can choose between the following types.

    AttributeDescription
    stringString attribute.
    integerInteger attribute.
    floatFloat attribute.
    booleanBoolean attribute.
    datetimeDatetime attribute formatted as an ISO 8601 string.
    enumEnum attribute.
    ipIP address attribute for IPv4 and IPv6.
    emailEmail address attribute.
    urlURL attribute.
    relationshipRelationship attribute relates one collection to another. Learn more about relationships.

    If an attribute must be populated in all documents, set it as required. If not, you may optionally set a default value. Additionally, decide if the attribute should be a single value or an array of values.

    If needed, you can change an attribute's key, default value, size (for strings), and whether it is required or not after creation.

    You can increase a string attribute's size without any restrictions. When decreasing size, you must ensure that your existing data is less than or equal to the new size, or the operation will fail.

    Indexes

    Databases use indexes to quickly locate data without having to search through every document for matches. To ensure the best performance, Appwrite recommends an index for every attribute queried. If you plan to query multiple attributes in a single query, creating an index with all queried attributes will yield optimal performance.

    The following indexes are currently supported:

    TypeDescription
    keyPlain Index to allow queries.
    uniqueUnique Index to disallow duplicates.
    fulltextFor searching within string attributes. Required for the search query method.

    You can create an index by navigating to your collection's Indexes tab or by using your favorite Server SDK.