V2
更新数据库
更新数据库标题、描述、图标、封面或属性 schema。
更新数据库
适用场景
当你要修改数据库标题、描述、图标、封面,或调整属性 schema 时使用这个接口。它适合做字段演进和结构修补。
接口信息
| 项目 | 内容 |
|---|---|
| 方法 | PATCH |
| 路径 | /v2/databases/:database_id |
| 请求体 | database 局部更新参数 |
| 返回 | database |
| Scope | databases.write |
权限要求
需要 databases.write。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
database_id | string | 是 | 数据库 ID。 |
title | rich_text[] | 否 | 数据库标题。 |
description | rich_text[] | 否 | 数据库描述。 |
icon | object | null | 否 | 数据库图标。 |
cover | object | null | 否 | 数据库封面。 |
properties | object | 否 | 属性 schema 的局部更新。某个 schema 可以传 null 表示删除。 |
in_trash | boolean | 否 | 回收站状态。 |
请求体示例:
{
"title": [
{
"type": "text",
"text": {
"content": "任务看板(新版)"
}
}
],
"description": [
{
"type": "text",
"text": {
"content": "用于管理发布流程与任务状态"
}
}
],
"icon": {
"type": "emoji",
"emoji": "🗂️"
},
"properties": {
"Priority": {
"name": "Priority",
"type": "select",
"select": {
"options": [
{ "name": "P0", "color": "red" },
{ "name": "P1", "color": "orange" }
]
}
},
"Status": null
},
"in_trash": false
}
响应结果
{
"object": "database",
"id": "66666666-6666-4666-8666-666666666666",
"title": [
{
"type": "text",
"text": {
"content": "任务看板(新版)",
"link": null
},
"plain_text": "任务看板(新版)",
"href": null
}
],
"description": [
{
"type": "text",
"text": {
"content": "用于管理发布流程与任务状态",
"link": null
},
"plain_text": "用于管理发布流程与任务状态",
"href": null
}
],
"properties": {
"Name": {
"id": "title",
"type": "title",
"name": "Name"
}
},
"in_trash": false
}
行为说明或限制
- 这是部分更新接口,不传的字段保持不变。
properties中某个 schema 传null时,会从数据库中删除该字段。properties中传入新 schema 时,会按字段名匹配或新增。title、description、icon、cover、in_trash都可以单独更新。
错误提示
400 validation_error:目标对象不是数据库,或属性更新不合法。401 unauthorized:token 无效或已过期。403 forbidden:缺少databases.write或无权访问该数据库。404 not_found:数据库不存在。
