appwrite-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAppwrite CLI
Appwrite CLI
Installation
安装
bash
undefinedbash
undefinednpm
npm
npm install -g appwrite-cli
npm install -g appwrite-cli
macOS (Homebrew)
macOS (Homebrew)
brew install appwrite
brew install appwrite
macOS / Linux (script)
macOS / Linux (脚本)
curl -sL https://appwrite.io/cli/install.sh | bash
curl -sL https://appwrite.io/cli/install.sh | bash
Windows (Scoop)
Windows (Scoop)
scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/scoop/appwrite.config.json
Verify installation:
```bash
appwrite -vscoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/scoop/appwrite.config.json
验证安装:
```bash
appwrite -vLogin & Initialization
登录与初始化
bash
undefinedbash
undefinedLogin to your account
登录你的账号
appwrite login
appwrite login
Login to a self-hosted instance
登录自托管实例
appwrite login --endpoint "https://your-instance.com/v1"
appwrite login --endpoint "https://your-instance.com/v1"
Initialize a project (creates appwrite.config.json)
初始化项目(创建appwrite.config.json)
appwrite init project
appwrite init project
Verify by fetching project info
通过获取项目信息验证
appwrite projects get --project-id "<PROJECT_ID>"
undefinedappwrite projects get --project-id "<PROJECT_ID>"
undefinedConfiguration
配置
bash
undefinedbash
undefinedAuthenticate with Appwrite
登录Appwrite进行身份验证
appwrite login
> For the full list of CLI commands, see [CLI Commands](https://appwrite.io/docs/tooling/command-line/commands).
> For headless / CI/CD usage, see [Non-Interactive Mode](https://appwrite.io/docs/tooling/command-line/non-interactive).appwrite login
> 完整的CLI命令列表,请查看 [CLI命令](https://appwrite.io/docs/tooling/command-line/commands)。
> 关于无头/CI/CD使用,请查看 [非交互式模式](https://appwrite.io/docs/tooling/command-line/non-interactive)。appwrite.config.json
appwrite.config.json
All resources are configured in a single file at the project root:
appwrite.config.jsonjson
{
"projectId": "<PROJECT_ID>",
"endpoint": "https://<REGION>.cloud.appwrite.io/v1",
"functions": [],
"sites": [],
"tablesDB": [],
"tables": [],
"buckets": [],
"teams": [],
"topics": []
}所有资源都在项目根目录的单个文件中配置:
appwrite.config.jsonjson
{
"projectId": "<PROJECT_ID>",
"endpoint": "https://<REGION>.cloud.appwrite.io/v1",
"functions": [],
"sites": [],
"tablesDB": [],
"tables": [],
"buckets": [],
"teams": [],
"topics": []
}Deploying Functions
部署函数
bash
undefinedbash
undefinedCreate a new function
创建新函数
appwrite init functions
appwrite init functions
Pull existing functions from Console
从控制台拉取现有函数
appwrite pull functions
appwrite pull functions
Deploy functions
部署函数
appwrite push functions
undefinedappwrite push functions
undefinedFunction configuration in appwrite.config.json
appwrite.config.json中的函数配置
json
{
"functions": [
{
"$id": "<FUNCTION_ID>",
"name": "userAuth",
"enabled": true,
"live": true,
"logging": true,
"runtime": "node-18.0",
"deployment": "<DEPLOYMENT_ID>",
"vars": [],
"events": [],
"schedule": "",
"timeout": 15,
"entrypoint": "userAuth.js",
"commands": "npm install",
"version": "v3",
"path": "functions/userAuth"
}
]
}json
{
"functions": [
{
"$id": "<FUNCTION_ID>",
"name": "userAuth",
"enabled": true,
"live": true,
"logging": true,
"runtime": "node-18.0",
"deployment": "<DEPLOYMENT_ID>",
"vars": [],
"events": [],
"schedule": "",
"timeout": 15,
"entrypoint": "userAuth.js",
"commands": "npm install",
"version": "v3",
"path": "functions/userAuth"
}
]
}Function commands
函数命令
| Command | Description |
|---|---|
| List all functions |
| Create a new function |
| Get a function by ID |
| Update a function |
| Delete a function |
| List all active runtimes |
| List deployments |
| Upload a new deployment |
| Set active deployment |
| Delete a deployment |
| Download deployment |
| Trigger execution |
| List execution logs |
| Get execution log |
| List variables |
| Create variable |
| Update variable |
| Delete variable |
| 命令 | 描述 |
|---|---|
| 列出所有函数 |
| 创建新函数 |
| 通过ID获取函数 |
| 更新函数 |
| 删除函数 |
| 列出所有可用运行时 |
| 列出部署记录 |
| 上传新部署包 |
| 设置活跃部署 |
| 删除部署记录 |
| 下载部署包 |
| 触发函数执行 |
| 列出执行日志 |
| 获取执行日志 |
| 列出环境变量 |
| 创建环境变量 |
| 更新环境变量 |
| 删除环境变量 |
Trigger a function with body
携带请求体触发函数
bash
appwrite functions create-execution \
--function-id <FUNCTION_ID> \
--body '{"key": "value"}'bash
appwrite functions create-execution \
--function-id <FUNCTION_ID> \
--body '{"key": "value"}'Local development
本地开发
bash
appwrite run functionsbash
appwrite run functionsDeploying Sites
部署站点
bash
undefinedbash
undefinedCreate a new site
创建新站点
appwrite init sites
appwrite init sites
Pull existing sites from Console
从控制台拉取现有站点
appwrite pull sites
appwrite pull sites
Deploy sites
部署站点
appwrite push sites
undefinedappwrite push sites
undefinedSite configuration in appwrite.config.json
appwrite.config.json中的站点配置
json
{
"sites": [
{
"$id": "<SITE_ID>",
"name": "Documentation template",
"enabled": true,
"logging": true,
"framework": "astro",
"timeout": 30,
"installCommand": "npm install",
"buildCommand": "npm run build",
"outputDirectory": "./dist",
"specification": "s-1vcpu-512mb",
"buildRuntime": "node-22",
"adapter": "ssr",
"fallbackFile": "",
"path": "sites/documentation-template"
}
]
}json
{
"sites": [
{
"$id": "<SITE_ID>",
"name": "Documentation template",
"enabled": true,
"logging": true,
"framework": "astro",
"timeout": 30,
"installCommand": "npm install",
"buildCommand": "npm run build",
"outputDirectory": "./dist",
"specification": "s-1vcpu-512mb",
"buildRuntime": "node-22",
"adapter": "ssr",
"fallbackFile": "",
"path": "sites/documentation-template"
}
]
}Site commands
站点命令
| Command | Description |
|---|---|
| List all sites |
| Create a new site |
| Get a site by ID |
| Update a site |
| Delete a site |
| List available frameworks |
| List allowed specs |
| List available templates |
| Get template details |
| List deployments |
| Create deployment |
| Get deployment |
| Delete deployment |
| Set active deployment |
| Cancel ongoing build |
| List variables |
| Create variable |
| Update variable |
| Delete variable |
| List request logs |
| Get a log |
| Delete a log |
| 命令 | 描述 |
|---|---|
| 列出所有站点 |
| 创建新站点 |
| 通过ID获取站点 |
| 更新站点 |
| 删除站点 |
| 列出可用框架 |
| 列出允许的配置规格 |
| 列出可用模板 |
| 获取模板详情 |
| 列出部署记录 |
| 创建部署 |
| 获取部署信息 |
| 删除部署记录 |
| 设置活跃部署 |
| 取消正在进行的构建 |
| 列出环境变量 |
| 创建环境变量 |
| 更新环境变量 |
| 删除环境变量 |
| 列出请求日志 |
| 获取单条日志 |
| 删除单条日志 |
Managing Tables (Databases)
管理数据表(数据库)
bash
undefinedbash
undefinedCreate a new table
创建新数据表
appwrite init tables
appwrite init tables
Pull existing tables from Console
从控制台拉取现有数据表
appwrite pull tables
appwrite pull tables
Deploy tables
部署数据表
appwrite push tables
undefinedappwrite push tables
undefinedTable configuration in appwrite.config.json
appwrite.config.json中的数据表配置
json
{
"tablesDB": [
{
"$id": "<DATABASE_ID>",
"name": "songs",
"enabled": true
}
],
"tables": [
{
"$id": "<TABLE_ID>",
"$permissions": ["create(\"any\")", "read(\"any\")"],
"databaseId": "<DATABASE_ID>",
"name": "music",
"enabled": true,
"rowSecurity": false,
"columns": [
{
"key": "title",
"type": "varchar",
"required": true,
"size": 255
}
],
"indexes": []
}
]
}json
{
"tablesDB": [
{
"$id": "<DATABASE_ID>",
"name": "songs",
"enabled": true
}
],
"tables": [
{
"$id": "<TABLE_ID>",
"$permissions": ["create(\"any\")", "read(\"any\")"],
"databaseId": "<DATABASE_ID>",
"name": "music",
"enabled": true,
"rowSecurity": false,
"columns": [
{
"key": "title",
"type": "varchar",
"required": true,
"size": 255
}
],
"indexes": []
}
]
}Database commands (TablesDB)
数据库命令(TablesDB)
| Command | Description |
|---|---|
| List tables |
| Create table |
| Get table |
| Update table |
| Delete table |
| List columns |
| Get column |
| Delete column |
| List indexes |
| Create index |
| Delete index |
| 命令 | 描述 |
|---|---|
| 列出数据表 |
| 创建数据表 |
| 获取数据表 |
| 更新数据表 |
| 删除数据表 |
| 列出列 |
| 获取列信息 |
| 删除列 |
| 列出索引 |
| 创建索引 |
| 删除索引 |
Column type commands
列类型命令
Note: The legacytype is deprecated. Use explicit string column types instead.string
| Command | Description |
|---|---|
| Varchar column — inline storage, fully indexable (max 16,383 chars, size ≤ 768 for full index) |
| Text column — off-page storage, prefix index only (max 16,383 chars) |
| Mediumtext column — off-page storage (max ~4M chars) |
| Longtext column — off-page storage (max ~1B chars) |
| Boolean column |
| Integer column (optional min/max) |
| Float column (optional min/max) |
| Email column |
| URL column |
| IP address column |
| Datetime column (ISO 8601) |
| Enum column (whitelist of accepted values) |
| Relationship column |
All column commands use .
appwrite tables-db <command> --database-id <ID> --table-id <ID>注意: 旧版类型已弃用,请使用明确的字符串列类型替代。string
| 命令 | 描述 |
|---|---|
| Varchar列 — 内联存储,支持全索引(最大16383字符,索引最大长度≤768) |
| Text列 — 离线存储,仅支持前缀索引(最大16383字符) |
| Mediumtext列 — 离线存储(最大约400万字符) |
| Longtext列 — 离线存储(最大约10亿字符) |
| 布尔列 |
| 整数列(可选最小值/最大值) |
| 浮点数列(可选最小值/最大值) |
| 邮箱列 |
| URL列 |
| IP地址列 |
| 日期时间列(ISO 8601格式) |
| 枚举列(仅接受白名单内的值) |
| 关联列 |
所有列命令均使用格式。
appwrite tables-db <command> --database-id <ID> --table-id <ID>Row operations
行操作
bash
undefinedbash
undefinedCreate a row
创建行
appwrite tables-db create-row
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>"
--row-id 'unique()' --data '{ "title": "Hello World" }'
--permissions 'read("any")' 'write("team:abc")'
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>"
--row-id 'unique()' --data '{ "title": "Hello World" }'
--permissions 'read("any")' 'write("team:abc")'
appwrite tables-db create-row
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>"
--row-id 'unique()' --data '{ "title": "Hello World" }'
--permissions 'read("any")' 'write("team:abc")'
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>"
--row-id 'unique()' --data '{ "title": "Hello World" }'
--permissions 'read("any")' 'write("team:abc")'
List rows (JSON output)
列出行(JSON输出)
appwrite tables-db list-rows
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --json
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --json
appwrite tables-db list-rows
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --json
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --json
Get a row
获取行
appwrite tables-db get-row
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --row-id "<ROW_ID>"
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --row-id "<ROW_ID>"
undefinedappwrite tables-db get-row
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --row-id "<ROW_ID>"
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --row-id "<ROW_ID>"
undefinedManaging Buckets (Storage)
管理存储桶(存储服务)
bash
undefinedbash
undefinedCreate a new bucket
创建新存储桶
appwrite init buckets
appwrite init buckets
Pull existing buckets from Console
从控制台拉取现有存储桶
appwrite pull buckets
appwrite pull buckets
Deploy buckets
部署存储桶
appwrite push buckets
undefinedappwrite push buckets
undefinedStorage commands
存储命令
| Command | Description |
|---|---|
| List all buckets |
| Create a bucket |
| Get a bucket |
| Update a bucket |
| Delete a bucket |
| List files |
| Upload a file |
| Get file metadata |
| Delete a file |
| Download a file |
| Get image preview |
| View file in browser |
| 命令 | 描述 |
|---|---|
| 列出所有存储桶 |
| 创建存储桶 |
| 获取存储桶信息 |
| 更新存储桶 |
| 删除存储桶 |
| 列出文件 |
| 上传文件 |
| 获取文件元数据 |
| 删除文件 |
| 下载文件 |
| 获取图片预览 |
| 在浏览器中查看文件 |
Managing Teams
管理团队
bash
undefinedbash
undefinedCreate a new team
创建新团队
appwrite init teams
appwrite init teams
Pull existing teams from Console
从控制台拉取现有团队
appwrite pull teams
appwrite pull teams
Deploy teams
部署团队配置
appwrite push teams
undefinedappwrite push teams
undefinedTeam commands
团队命令
| Command | Description |
|---|---|
| List all teams |
| Create a team |
| Get a team |
| Update team name |
| Delete a team |
| List members |
| Invite a member |
| Update member roles |
| Remove a member |
| Get team preferences |
| Update team preferences |
| 命令 | 描述 |
|---|---|
| 列出所有团队 |
| 创建团队 |
| 获取团队信息 |
| 更新团队名称 |
| 删除团队 |
| 列出团队成员 |
| 邀请成员加入团队 |
| 更新成员角色 |
| 移除团队成员 |
| 获取团队偏好设置 |
| 更新团队偏好设置 |
Managing Topics (Messaging)
管理主题(消息服务)
bash
undefinedbash
undefinedCreate a new topic
创建新主题
appwrite init topics
appwrite init topics
Pull existing topics from Console
从控制台拉取现有主题
appwrite pull topics
appwrite pull topics
Deploy topics
部署主题配置
appwrite push topics
undefinedappwrite push topics
undefinedMessaging commands
消息服务命令
| Command | Description |
|---|---|
| List all messages |
| Create email message |
| Create push notification |
| Create SMS message |
| Get a message |
| Delete a message |
| List all topics |
| Create a topic |
| Get a topic |
| Update a topic |
| Delete a topic |
| List subscribers |
| Add subscriber |
| Remove subscriber |
| 命令 | 描述 |
|---|---|
| 列出所有消息 |
| 创建邮件消息 |
| 创建推送通知 |
| 创建短信消息 |
| 获取消息信息 |
| 删除消息 |
| 列出所有主题 |
| 创建主题 |
| 获取主题信息 |
| 更新主题 |
| 删除主题 |
| 列出订阅者 |
| 添加订阅者 |
| 移除订阅者 |
User Management
用户管理
bash
undefinedbash
undefinedCreate a user
创建用户
appwrite users create --user-id "unique()"
--email hello@appwrite.io
--email hello@appwrite.io
appwrite users create --user-id "unique()"
--email hello@appwrite.io
--email hello@appwrite.io
List users
列出用户
appwrite users list
appwrite users list
Get a user
获取用户信息
appwrite users get --user-id "<USER_ID>"
appwrite users get --user-id "<USER_ID>"
Delete a user
删除用户
appwrite users delete --user-id "<USER_ID>"
undefinedappwrite users delete --user-id "<USER_ID>"
undefinedGenerate Type-Safe SDK
生成类型安全SDK
bash
undefinedbash
undefinedAuto-detect language and generate
自动检测语言并生成
appwrite generate
appwrite generate
Specify output directory
指定输出目录
appwrite generate --output ./src/generated
appwrite generate --output ./src/generated
Specify language
指定语言
appwrite generate --language typescript
Generated files:
| File | Description |
|------|-------------|
| `types.ts` | Type definitions from your database schema |
| `databases.ts` | Typed database helpers for querying and mutating rows |
| `constants.ts` | Configuration constants (endpoint, project ID) |
| `index.ts` | Entry point that exports all helpers |
Usage:
```typescript
import { databases } from "./generated/appwrite";
const customers = databases.use("main").use("customers");
// Create
const customer = await customers.create({
name: "Walter O' Brian",
email: "walter@example.com"
});
// List with typed queries
const results = await customers.list({
queries: (q) => [
q.equal("name", "Walter O' Brian"),
q.orderDesc("$createdAt"),
q.limit(10)
]
});
// Update
await customers.update("customer-id-123", {
email: "walter@scorpion.com"
});
// Delete
await customers.delete("customer-id-123");
// Bulk create
await customers.createMany([
{ name: "Walter O' Brian", email: "walter@example.com" },
{ name: "Paige Dineen", email: "paige@example.com" }
]);appwrite generate --language typescript
生成的文件:
| 文件 | 描述 |
|------|-------------|
| `types.ts` | 来自数据库 schema 的类型定义 |
| `databases.ts` | 用于查询和修改数据行的类型化数据库工具 |
| `constants.ts` | 配置常量(端点、项目ID) |
| `index.ts` | 导出所有工具的入口文件 |
使用示例:
```typescript
import { databases } from "./generated/appwrite";
const customers = databases.use("main").use("customers");
// 创建
const customer = await customers.create({
name: "Walter O' Brian",
email: "walter@example.com"
});
// 带类型化查询条件列出数据
const results = await customers.list({
queries: (q) => [
q.equal("name", "Walter O' Brian"),
q.orderDesc("$createdAt"),
q.limit(10)
]
});
// 更新
await customers.update("customer-id-123", {
email: "walter@scorpion.com"
});
// 删除
await customers.delete("customer-id-123");
// 批量创建
await customers.createMany([
{ name: "Walter O' Brian", email: "walter@example.com" },
{ name: "Paige Dineen", email: "paige@example.com" }
]);Non-Interactive / CI/CD Mode
非交互式/CI/CD模式
For headless automation, see the Non-Interactive Mode docs.
关于无头自动化,请查看 非交互式模式文档。
Deploy non-interactively
非交互式部署
bash
undefinedbash
undefinedPush everything
推送所有资源
appwrite push all --all --force
appwrite push all --all --force
Push specific resources
推送指定资源
appwrite push functions --all --force
appwrite push functions --function-id <FUNCTION_ID> --force
appwrite push sites --all --force
appwrite push tables --all --force
appwrite push teams --all --force
appwrite push buckets --all --force
appwrite push topics --all --force
undefinedappwrite push functions --all --force
appwrite push functions --function-id <FUNCTION_ID> --force
appwrite push sites --all --force
appwrite push tables --all --force
appwrite push teams --all --force
appwrite push buckets --all --force
appwrite push topics --all --force
undefinedGlobal Command Options
全局命令选项
| Option | Description |
|---|---|
| Output version number |
| Show complete error log |
| Output in JSON format |
| Confirm all warnings |
| Select all resources |
| Pass a list of IDs |
| Generate GitHub error report link |
| Get direct link to Console |
| Open Console link in browser |
| Display help |
| 选项 | 描述 |
|---|---|
| 输出版本号 |
| 显示完整错误日志 |
| 以JSON格式输出 |
| 确认所有警告 |
| 选择所有资源 |
| 传入ID列表 |
| 生成GitHub错误报告链接 |
| 获取控制台直接链接 |
| 在浏览器中打开控制台链接 |
| 显示帮助信息 |
Examples
示例
bash
undefinedbash
undefinedList users with JSON output
以JSON格式列出用户
appwrite users list --json
appwrite users list --json
Get verbose error output
获取详细错误输出
appwrite users list --verbose
appwrite users list --verbose
View a row in the Console
在控制台中查看行数据
appwrite tables-db get-row
--database-id "<DATABASE_ID>"
--table-id "<TABLE_ID>"
--row-id "<ROW_ID>"
--console --open
--database-id "<DATABASE_ID>"
--table-id "<TABLE_ID>"
--row-id "<ROW_ID>"
--console --open
appwrite tables-db get-row
--database-id "<DATABASE_ID>"
--table-id "<TABLE_ID>"
--row-id "<ROW_ID>"
--console --open
--database-id "<DATABASE_ID>"
--table-id "<TABLE_ID>"
--row-id "<ROW_ID>"
--console --open
Generate error report
生成错误报告
appwrite login --report
undefinedappwrite login --report
undefined