dab update
修改配置文件中已有的实体定义。用于调整权限、REST / GraphQL 暴露方式、策略、缓存、关系、字段映射和描述信息。
语法
bash
dab update <entity-name> [options]选项
基本
| 选项 | 说明 |
|---|---|
-c, --config | 配置文件路径 |
源(Source)选项
| 选项 | 说明 |
|---|---|
-s, --source | 更新底层数据库对象名 |
--source.type | 更新对象类型:table、view、stored-procedure |
权限选项
| 选项 | 说明 |
|---|---|
--permissions | "role:actions" 格式。注意:覆盖式更新,非合并 |
--policy-database | 数据库策略表达式(配合 --permissions 使用) |
字段选项
| 选项 | 说明 |
|---|---|
--fields.name | 数据库字段名 |
--fields.alias | API 层字段别名 |
--fields.description | 字段描述 |
--fields.primary-key | 标记为视图主键(true / false) |
--fields.include | 允许暴露的字段列表 |
--fields.exclude | 排除的字段列表 |
REST 选项
| 选项 | 说明 | 默认值 |
|---|---|---|
--rest.enabled | 是否生成 REST 端点 | true |
--rest.path | 自定义 REST 路径 | 实体名 |
--rest.methods | 允许的 HTTP 方法(仅存储过程) | ["POST"] |
GraphQL 选项
| 选项 | 说明 | 默认值 |
|---|---|---|
--graphql.enabled | 是否出现在 GraphQL 架构中 | true |
--graphql.type.singular | GraphQL 单数类型名 | — |
--graphql.type.plural | GraphQL 复数类型名 | — |
--graphql.operation | 存储过程挂载位置 | mutation |
缓存选项
| 选项 | 说明 | 默认值 |
|---|---|---|
--cache.enabled | 是否启用缓存 | false |
--cache.ttl-seconds | 缓存 TTL(秒) | — |
--cache.level | 缓存级别:L1 / L1L2 | L1L2 |
MCP 选项
| 选项 | 说明 |
|---|---|
--mcp.dml-tools | 是否暴露 MCP DML 工具 |
--mcp.custom-tool | 是否注册为 MCP 自定义工具(仅存储过程) |
关系选项
| 选项 | 说明 |
|---|---|
--relationship | 关系名称 |
--target.entity | 目标实体名 |
--cardinality | 关系基数:one 或 many |
--relationship.fields | 关联字段,格式 "sourceField:targetField" |
--linking.object | 多对多联接表名 |
--linking.source.fields | 联接表中指向源的字段 |
--linking.target.fields | 联接表中指向目标的字段 |
存储过程参数选项
| 选项 | 说明 |
|---|---|
--parameters.name | 参数名列表(逗号分隔) |
--parameters.required | 是否必需(true,false,...) |
--parameters.default | 默认值列表(逗号分隔) |
--parameters.description | 参数描述列表(逗号分隔) |
其他
| 选项 | 说明 |
|---|---|
--description | 更新实体描述 |
--health.enabled | 启用/禁用实体健康检查 |
示例
更新权限
bash
dab update Book --permissions "authenticated:read,create,update"WARNING
--permissions 是覆盖式更新。新值会替换该角色的全部现有权限,不会与已有权限合并。
添加关系
bash
dab update Book \
--relationship book_category \
--target.entity Category \
--cardinality one \
--relationship.fields "category_id:id"添加多对多关系
bash
dab update Book \
--relationship book_authors \
--target.entity Author \
--cardinality many \
--relationship.fields "id:id" \
--linking.object "dbo.Book_Authors" \
--linking.source.fields "book_id" \
--linking.target.fields "author_id"启用缓存
bash
dab update Product --cache.enabled true --cache.ttl-seconds 60更新字段描述
bash
dab update Product \
--fields.name "UnitPrice" \
--fields.description "零售单价,单位为人民币元"配置 MCP 自定义工具
bash
dab update GetBookById --mcp.custom-tool true注意事项
- 修改
source.type时可能导致其他属性失效。 - 视图始终需要主键字段。
- 实体级复杂权限、关系与策略变更后建议立即运行
dab validate。 - 字段映射使用
--fields.name+--fields.alias组合。
下一步
- dab add — 添加新实体。
- dab validate — 验证配置。
