Appwrite Databases supports bulk operations for rows, allowing you to create, update, or delete multiple rows in a single request. This can significantly improve performance for apps as it allows you to reduce the number of API calls needed while working with large data sets.
Bulk operations can only be performed via the server-side SDKs. The client-side SDKs do not support bulk operations by design to prevent abuse and protect against unexpected costs. This ensures that only trusted server environments can perform large-scale data operations.
For client applications that need bulk-like functionality, consider using Appwrite Functions with proper rate limiting and validation.
Atomic behavior
Bulk operations in Appwrite are atomic, meaning they follow an all-or-nothing approach. Either all rows in your bulk request succeed, or all rows fail.
This atomicity ensures:
- Data consistency: Your database remains in a consistent state even if some operations would fail.
- Race condition prevention: Multiple clients can safely perform bulk operations simultaneously.
- Simplified error handling: You only need to handle complete success or complete failure scenarios.
For example, if you attempt to create 100 rows and one fails due to a validation error, none of the 100 rows will be created.
Create rows
You can create multiple rows in a single request using the createRows
method.
Custom timestamps
When creating, updating or upserting in bulk, you can set $createdAt
and $updatedAt
for each document in the payload. Values must be ISO 8601 date-time strings. If omitted, Appwrite sets them automatically.
Update rows
Permissions required
You must grant update permissions to users at the table level before users can update rows. Learn more about permissions
You can update multiple rows in a single request using the updateRows
method.
Upsert rows
Permissions required
You must grant create and update permissions to users at the table level before users can create rows. Learn more about permissions
You can upsert multiple rows in a single request using the upsertRows(
method.
Delete rows
Permissions required
You must grant delete permissions to users at the table level before users can delete rows. Learn more about permissions
You can delete multiple rows in a single request using the deleteRows
method.
Queries for deletion
When deleting rows, you must specify queries to filter which rows to delete. If no queries are provided, all rows in the table will be deleted. Learn more about queries.