appwrite-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Appwrite CLI

Appwrite CLI

Installation

安装

bash
undefined
bash
undefined

npm

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 (脚本)

Windows (Scoop)

Windows (Scoop)

Login & Initialization

登录与初始化

bash
undefined
bash
undefined

Login 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>"
undefined
appwrite projects get --project-id "<PROJECT_ID>"
undefined

Configuration

配置

bash
undefined
bash
undefined

Authenticate 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
appwrite.config.json
file at the project root:
json
{
    "projectId": "<PROJECT_ID>",
    "endpoint": "https://<REGION>.cloud.appwrite.io/v1",
    "functions": [],
    "sites": [],
    "tablesDB": [],
    "tables": [],
    "buckets": [],
    "teams": [],
    "topics": []
}
所有资源都在项目根目录的单个
appwrite.config.json
文件中配置:
json
{
    "projectId": "<PROJECT_ID>",
    "endpoint": "https://<REGION>.cloud.appwrite.io/v1",
    "functions": [],
    "sites": [],
    "tablesDB": [],
    "tables": [],
    "buckets": [],
    "teams": [],
    "topics": []
}

Deploying Functions

部署函数

bash
undefined
bash
undefined

Create 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
undefined
appwrite push functions
undefined

Function 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

函数命令

CommandDescription
appwrite functions list
List all functions
appwrite functions create
Create a new function
appwrite functions get --function-id <ID>
Get a function by ID
appwrite functions update --function-id <ID>
Update a function
appwrite functions delete --function-id <ID>
Delete a function
appwrite functions list-runtimes
List all active runtimes
appwrite functions list-deployments --function-id <ID>
List deployments
appwrite functions create-deployment --function-id <ID>
Upload a new deployment
appwrite functions update-deployment --function-id <ID> --deployment-id <ID>
Set active deployment
appwrite functions delete-deployment --function-id <ID> --deployment-id <ID>
Delete a deployment
appwrite functions download-deployment --function-id <ID> --deployment-id <ID>
Download deployment
appwrite functions create-execution --function-id <ID>
Trigger execution
appwrite functions list-executions --function-id <ID>
List execution logs
appwrite functions get-execution --function-id <ID> --execution-id <ID>
Get execution log
appwrite functions list-variables --function-id <ID>
List variables
appwrite functions create-variable --function-id <ID> --key <KEY> --value <VALUE>
Create variable
appwrite functions update-variable --function-id <ID> --variable-id <ID> --key <KEY> --value <VALUE>
Update variable
appwrite functions delete-variable --function-id <ID> --variable-id <ID>
Delete variable
命令描述
appwrite functions list
列出所有函数
appwrite functions create
创建新函数
appwrite functions get --function-id <ID>
通过ID获取函数
appwrite functions update --function-id <ID>
更新函数
appwrite functions delete --function-id <ID>
删除函数
appwrite functions list-runtimes
列出所有可用运行时
appwrite functions list-deployments --function-id <ID>
列出部署记录
appwrite functions create-deployment --function-id <ID>
上传新部署包
appwrite functions update-deployment --function-id <ID> --deployment-id <ID>
设置活跃部署
appwrite functions delete-deployment --function-id <ID> --deployment-id <ID>
删除部署记录
appwrite functions download-deployment --function-id <ID> --deployment-id <ID>
下载部署包
appwrite functions create-execution --function-id <ID>
触发函数执行
appwrite functions list-executions --function-id <ID>
列出执行日志
appwrite functions get-execution --function-id <ID> --execution-id <ID>
获取执行日志
appwrite functions list-variables --function-id <ID>
列出环境变量
appwrite functions create-variable --function-id <ID> --key <KEY> --value <VALUE>
创建环境变量
appwrite functions update-variable --function-id <ID> --variable-id <ID> --key <KEY> --value <VALUE>
更新环境变量
appwrite functions delete-variable --function-id <ID> --variable-id <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 functions
bash
appwrite run functions

Deploying Sites

部署站点

bash
undefined
bash
undefined

Create 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
undefined
appwrite push sites
undefined

Site 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

站点命令

CommandDescription
appwrite sites list
List all sites
appwrite sites create
Create a new site
appwrite sites get --site-id <ID>
Get a site by ID
appwrite sites update --site-id <ID>
Update a site
appwrite sites delete --site-id <ID>
Delete a site
appwrite sites list-frameworks
List available frameworks
appwrite sites list-specifications
List allowed specs
appwrite sites list-templates
List available templates
appwrite sites get-template --template-id <ID>
Get template details
appwrite sites list-deployments --site-id <ID>
List deployments
appwrite sites create-deployment --site-id <ID>
Create deployment
appwrite sites get-deployment --site-id <ID> --deployment-id <ID>
Get deployment
appwrite sites delete-deployment --site-id <ID> --deployment-id <ID>
Delete deployment
appwrite sites update-site-deployment --site-id <ID> --deployment-id <ID>
Set active deployment
appwrite sites update-deployment-status --site-id <ID> --deployment-id <ID>
Cancel ongoing build
appwrite sites list-variables --site-id <ID>
List variables
appwrite sites create-variable --site-id <ID> --key <KEY> --value <VALUE>
Create variable
appwrite sites update-variable --site-id <ID> --variable-id <ID> --key <KEY> --value <VALUE>
Update variable
appwrite sites delete-variable --site-id <ID> --variable-id <ID>
Delete variable
appwrite sites list-logs --site-id <ID>
List request logs
appwrite sites get-log --site-id <ID> --log-id <ID>
Get a log
appwrite sites delete-log --site-id <ID> --log-id <ID>
Delete a log
命令描述
appwrite sites list
列出所有站点
appwrite sites create
创建新站点
appwrite sites get --site-id <ID>
通过ID获取站点
appwrite sites update --site-id <ID>
更新站点
appwrite sites delete --site-id <ID>
删除站点
appwrite sites list-frameworks
列出可用框架
appwrite sites list-specifications
列出允许的配置规格
appwrite sites list-templates
列出可用模板
appwrite sites get-template --template-id <ID>
获取模板详情
appwrite sites list-deployments --site-id <ID>
列出部署记录
appwrite sites create-deployment --site-id <ID>
创建部署
appwrite sites get-deployment --site-id <ID> --deployment-id <ID>
获取部署信息
appwrite sites delete-deployment --site-id <ID> --deployment-id <ID>
删除部署记录
appwrite sites update-site-deployment --site-id <ID> --deployment-id <ID>
设置活跃部署
appwrite sites update-deployment-status --site-id <ID> --deployment-id <ID>
取消正在进行的构建
appwrite sites list-variables --site-id <ID>
列出环境变量
appwrite sites create-variable --site-id <ID> --key <KEY> --value <VALUE>
创建环境变量
appwrite sites update-variable --site-id <ID> --variable-id <ID> --key <KEY> --value <VALUE>
更新环境变量
appwrite sites delete-variable --site-id <ID> --variable-id <ID>
删除环境变量
appwrite sites list-logs --site-id <ID>
列出请求日志
appwrite sites get-log --site-id <ID> --log-id <ID>
获取单条日志
appwrite sites delete-log --site-id <ID> --log-id <ID>
删除单条日志

Managing Tables (Databases)

管理数据表(数据库)

bash
undefined
bash
undefined

Create 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
undefined
appwrite push tables
undefined

Table 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)

CommandDescription
appwrite tables-db list-tables --database-id <ID>
List tables
appwrite tables-db create-table --database-id <ID>
Create table
appwrite tables-db get-table --database-id <ID> --table-id <ID>
Get table
appwrite tables-db update-table --database-id <ID> --table-id <ID>
Update table
appwrite tables-db delete-table --database-id <ID> --table-id <ID>
Delete table
appwrite tables-db list-columns --database-id <ID> --table-id <ID>
List columns
appwrite tables-db get-column --database-id <ID> --table-id <ID> --key <KEY>
Get column
appwrite tables-db delete-column --database-id <ID> --table-id <ID> --key <KEY>
Delete column
appwrite tables-db list-column-indexes --database-id <ID> --table-id <ID>
List indexes
appwrite tables-db create-column-index --database-id <ID> --table-id <ID>
Create index
appwrite tables-db delete-column-index --database-id <ID> --table-id <ID> --key <KEY>
Delete index
命令描述
appwrite tables-db list-tables --database-id <ID>
列出数据表
appwrite tables-db create-table --database-id <ID>
创建数据表
appwrite tables-db get-table --database-id <ID> --table-id <ID>
获取数据表
appwrite tables-db update-table --database-id <ID> --table-id <ID>
更新数据表
appwrite tables-db delete-table --database-id <ID> --table-id <ID>
删除数据表
appwrite tables-db list-columns --database-id <ID> --table-id <ID>
列出列
appwrite tables-db get-column --database-id <ID> --table-id <ID> --key <KEY>
获取列信息
appwrite tables-db delete-column --database-id <ID> --table-id <ID> --key <KEY>
删除列
appwrite tables-db list-column-indexes --database-id <ID> --table-id <ID>
列出索引
appwrite tables-db create-column-index --database-id <ID> --table-id <ID>
创建索引
appwrite tables-db delete-column-index --database-id <ID> --table-id <ID> --key <KEY>
删除索引

Column type commands

列类型命令

Note: The legacy
string
type is deprecated. Use explicit string column types instead.
CommandDescription
create-varchar-column
Varchar column — inline storage, fully indexable (max 16,383 chars, size ≤ 768 for full index)
create-text-column
Text column — off-page storage, prefix index only (max 16,383 chars)
create-mediumtext-column
Mediumtext column — off-page storage (max ~4M chars)
create-longtext-column
Longtext column — off-page storage (max ~1B chars)
create-boolean-column
Boolean column
create-integer-column
Integer column (optional min/max)
create-float-column
Float column (optional min/max)
create-email-column
Email column
create-url-column
URL column
create-ip-column
IP address column
create-datetime-column
Datetime column (ISO 8601)
create-enum-column
Enum column (whitelist of accepted values)
create-relationship-column
Relationship column
All column commands use
appwrite tables-db <command> --database-id <ID> --table-id <ID>
.
注意: 旧版
string
类型已弃用,请使用明确的字符串列类型替代。
命令描述
create-varchar-column
Varchar列 — 内联存储,支持全索引(最大16383字符,索引最大长度≤768)
create-text-column
Text列 — 离线存储,仅支持前缀索引(最大16383字符)
create-mediumtext-column
Mediumtext列 — 离线存储(最大约400万字符)
create-longtext-column
Longtext列 — 离线存储(最大约10亿字符)
create-boolean-column
布尔列
create-integer-column
整数列(可选最小值/最大值)
create-float-column
浮点数列(可选最小值/最大值)
create-email-column
邮箱列
create-url-column
URL列
create-ip-column
IP地址列
create-datetime-column
日期时间列(ISO 8601格式)
create-enum-column
枚举列(仅接受白名单内的值)
create-relationship-column
关联列
所有列命令均使用
appwrite tables-db <command> --database-id <ID> --table-id <ID>
格式。

Row operations

行操作

bash
undefined
bash
undefined

Create 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")'
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")'

List rows (JSON output)

列出行(JSON输出)

appwrite tables-db list-rows
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --json
appwrite tables-db list-rows
--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>"
undefined
appwrite tables-db get-row
--database-id "<DATABASE_ID>" --table-id "<TABLE_ID>" --row-id "<ROW_ID>"
undefined

Managing Buckets (Storage)

管理存储桶(存储服务)

bash
undefined
bash
undefined

Create 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
undefined
appwrite push buckets
undefined

Storage commands

存储命令

CommandDescription
appwrite storage list-buckets
List all buckets
appwrite storage create-bucket
Create a bucket
appwrite storage get-bucket --bucket-id <ID>
Get a bucket
appwrite storage update-bucket --bucket-id <ID>
Update a bucket
appwrite storage delete-bucket --bucket-id <ID>
Delete a bucket
appwrite storage list-files --bucket-id <ID>
List files
appwrite storage create-file --bucket-id <ID>
Upload a file
appwrite storage get-file --bucket-id <ID> --file-id <ID>
Get file metadata
appwrite storage delete-file --bucket-id <ID> --file-id <ID>
Delete a file
appwrite storage get-file-download --bucket-id <ID> --file-id <ID>
Download a file
appwrite storage get-file-preview --bucket-id <ID> --file-id <ID>
Get image preview
appwrite storage get-file-view --bucket-id <ID> --file-id <ID>
View file in browser
命令描述
appwrite storage list-buckets
列出所有存储桶
appwrite storage create-bucket
创建存储桶
appwrite storage get-bucket --bucket-id <ID>
获取存储桶信息
appwrite storage update-bucket --bucket-id <ID>
更新存储桶
appwrite storage delete-bucket --bucket-id <ID>
删除存储桶
appwrite storage list-files --bucket-id <ID>
列出文件
appwrite storage create-file --bucket-id <ID>
上传文件
appwrite storage get-file --bucket-id <ID> --file-id <ID>
获取文件元数据
appwrite storage delete-file --bucket-id <ID> --file-id <ID>
删除文件
appwrite storage get-file-download --bucket-id <ID> --file-id <ID>
下载文件
appwrite storage get-file-preview --bucket-id <ID> --file-id <ID>
获取图片预览
appwrite storage get-file-view --bucket-id <ID> --file-id <ID>
在浏览器中查看文件

Managing Teams

管理团队

bash
undefined
bash
undefined

Create 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
undefined
appwrite push teams
undefined

Team commands

团队命令

CommandDescription
appwrite teams list
List all teams
appwrite teams create
Create a team
appwrite teams get --team-id <ID>
Get a team
appwrite teams update-name --team-id <ID>
Update team name
appwrite teams delete --team-id <ID>
Delete a team
appwrite teams list-memberships --team-id <ID>
List members
appwrite teams create-membership --team-id <ID>
Invite a member
appwrite teams update-membership --team-id <ID> --membership-id <ID>
Update member roles
appwrite teams delete-membership --team-id <ID> --membership-id <ID>
Remove a member
appwrite teams get-prefs --team-id <ID>
Get team preferences
appwrite teams update-prefs --team-id <ID>
Update team preferences
命令描述
appwrite teams list
列出所有团队
appwrite teams create
创建团队
appwrite teams get --team-id <ID>
获取团队信息
appwrite teams update-name --team-id <ID>
更新团队名称
appwrite teams delete --team-id <ID>
删除团队
appwrite teams list-memberships --team-id <ID>
列出团队成员
appwrite teams create-membership --team-id <ID>
邀请成员加入团队
appwrite teams update-membership --team-id <ID> --membership-id <ID>
更新成员角色
appwrite teams delete-membership --team-id <ID> --membership-id <ID>
移除团队成员
appwrite teams get-prefs --team-id <ID>
获取团队偏好设置
appwrite teams update-prefs --team-id <ID>
更新团队偏好设置

Managing Topics (Messaging)

管理主题(消息服务)

bash
undefined
bash
undefined

Create 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
undefined
appwrite push topics
undefined

Messaging commands

消息服务命令

CommandDescription
appwrite messaging list-messages
List all messages
appwrite messaging create-email
Create email message
appwrite messaging create-push
Create push notification
appwrite messaging create-sms
Create SMS message
appwrite messaging get-message --message-id <ID>
Get a message
appwrite messaging delete --message-id <ID>
Delete a message
appwrite messaging list-topics
List all topics
appwrite messaging create-topic
Create a topic
appwrite messaging get-topic --topic-id <ID>
Get a topic
appwrite messaging update-topic --topic-id <ID>
Update a topic
appwrite messaging delete-topic --topic-id <ID>
Delete a topic
appwrite messaging list-subscribers --topic-id <ID>
List subscribers
appwrite messaging create-subscriber --topic-id <ID>
Add subscriber
appwrite messaging delete-subscriber --topic-id <ID> --subscriber-id <ID>
Remove subscriber
命令描述
appwrite messaging list-messages
列出所有消息
appwrite messaging create-email
创建邮件消息
appwrite messaging create-push
创建推送通知
appwrite messaging create-sms
创建短信消息
appwrite messaging get-message --message-id <ID>
获取消息信息
appwrite messaging delete --message-id <ID>
删除消息
appwrite messaging list-topics
列出所有主题
appwrite messaging create-topic
创建主题
appwrite messaging get-topic --topic-id <ID>
获取主题信息
appwrite messaging update-topic --topic-id <ID>
更新主题
appwrite messaging delete-topic --topic-id <ID>
删除主题
appwrite messaging list-subscribers --topic-id <ID>
列出订阅者
appwrite messaging create-subscriber --topic-id <ID>
添加订阅者
appwrite messaging delete-subscriber --topic-id <ID> --subscriber-id <ID>
移除订阅者

User Management

用户管理

bash
undefined
bash
undefined

Create a user

创建用户

appwrite users create --user-id "unique()"
--email hello@appwrite.io
appwrite users create --user-id "unique()"
--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>"
undefined
appwrite users delete --user-id "<USER_ID>"
undefined

Generate Type-Safe SDK

生成类型安全SDK

bash
undefined
bash
undefined

Auto-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
undefined
bash
undefined

Push 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
undefined
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
undefined

Global Command Options

全局命令选项

OptionDescription
-v, --version
Output version number
-V, --verbose
Show complete error log
-j, --json
Output in JSON format
-f, --force
Confirm all warnings
-a, --all
Select all resources
--id [id...]
Pass a list of IDs
--report
Generate GitHub error report link
--console
Get direct link to Console
--open
Open Console link in browser
-h, --help
Display help
选项描述
-v, --version
输出版本号
-V, --verbose
显示完整错误日志
-j, --json
以JSON格式输出
-f, --force
确认所有警告
-a, --all
选择所有资源
--id [id...]
传入ID列表
--report
生成GitHub错误报告链接
--console
获取控制台直接链接
--open
在浏览器中打开控制台链接
-h, --help
显示帮助信息

Examples

示例

bash
undefined
bash
undefined

List 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
appwrite tables-db get-row
--database-id "<DATABASE_ID>"
--table-id "<TABLE_ID>"
--row-id "<ROW_ID>"
--console --open

Generate error report

生成错误报告

appwrite login --report
undefined
appwrite login --report
undefined