通过


Entities

数据库实体的配置设置。

Health

Property Description
entities.entity-name.health.enabled 为实体启用运行状况检查(REST 和 GraphQL 终结点)
entities.entity-name.health.first 运行状况检查查询中返回的行数(范围:1-500)
entities.entity-name.health.threshold-ms 运行状况检查查询的最大持续时间(最小值:1)

Description

Property Description
entities.entity-name.description 实体的可读说明

Fields

Property Description
entities.entity-name.fields[].name 数据库字段名称(必需)
entities.entity-name.fields[].alias API 公开的名称(替换映射)
entities.entity-name.fields[].description 人工可读字段说明
entities.entity-name.fields[].primary-key 将字段标记为主键(替换键字段)

Source

Property Description
entities.entity-name.source.type 对象类型:table、或 viewstored-procedure
entities.entity-name.source.object 数据库对象的名称
entities.entity-name.source.object-description 数据库对象的人工可读说明
entities.entity-name.source.parameters 存储过程或函数的参数
entities.entity-name.source.key-fields 视图的主键字段列表 (已弃用)
entities.entity-name.mappings 将 API 字段名称映射到数据库列 (已弃用)

REST

Property Description
entities.entity-name.rest.enabled 为此实体启用 REST
entities.entity-name.rest.path REST 终结点的自定义路由
entities.entity-name.rest.methods 允许的 REST 方法:get、、postputpatchdelete

GraphQL

Property Description
entities.entity-name.graphql.type 使用 singular 键入名称或对象 plural
entities.entity-name.graphql.operation 作类型: querymutation
entities.entity-name.graphql.enabled 为此实体启用 GraphQL

Permissions

Property Description
entities.entity-name.permissions[].role 角色名称字符串
entities.entity-name.permissions[].actions 一个或多个:create、、readupdatedeleteexecute

Relationships

Property Description
entities.entity-name.relationships.relationship-name.cardinality onemany
entities.entity-name.relationships.relationship-name.target.entity 目标实体的名称
entities.entity-name.relationships.relationship-name.source.fields 关系中使用的此实体的字段
entities.entity-name.relationships.relationship-name.target.fields 来自目标实体的字段
entities.entity-name.relationships.relationship-name.linking.object 用于多对多关系的联接对象
entities.entity-name.relationships.relationship-name.linking.source.fields 联接中使用的源实体的字段
entities.entity-name.relationships.relationship-name.linking.target.fields 联接中使用的目标实体的字段

Cache

Property Description
entities.entity-name.cache.enabled 为实体启用响应缓存
entities.entity-name.cache.ttl-seconds 缓存生存时间(以秒为单位)
entities.entity-name.cache.level 缓存级别: L1 (仅内存中)或 L1L2 (内存中 + 分布式)

MCP

Property Description
entities.entity-name.mcp 控制实体的模型上下文协议(MCP)参与的对象
entities.entity-name.mcp.dml-tools 启用或禁用实体的数据操作语言 (DML) 工具
entities.entity-name.mcp.custom-tool 将存储过程注册为命名 MCP 工具(仅存储过程实体)

格式概述

{
  "entities": {
    "{entity-name}": {
      "description": <string>,
      "rest": {
        "enabled": <boolean> // default: true
        "path": <string> // default: "{entity-name}"
        "methods": ["GET", "POST"] // default: ["GET", "POST"]
      },
      "graphql": {
        "enabled": <boolean> // default: true
        "type": {
          "singular": <string>,
          "plural": <string>
        },
        "operation": "query" | "mutation" // default: "query"
      },
      "source": {
        "object": <string>,
        "object-description": <string>,
        "type": "view" | "stored-procedure" | "table",
        "key-fields": [<string>], // DEPRECATED: use fields[].primary-key
        "parameters": [ // array format (preferred)
          {
            "name": "<parameter-name>",
            "required": <boolean>,
            "default": <value>,
            "description": "<string>"
          }
        ]
      },
      "fields": [
        {
          "name": "<database-field-name>",
          "alias": "<api-exposed-name>",
          "description": "<string>",
          "primary-key": <boolean>
        }
      ],
      "mappings": { // DEPRECATED: use fields[].alias
        "<database-field-name>": <string>
      },
      "relationships": {
        "<relationship-name>": {
          "cardinality": "one" | "many",
          "target.entity": <string>,
          "source.fields": [<string>],
          "target.fields": [<string>],
          "linking.object": <string>,
          "linking.source.fields": [<string>],
          "linking.target.fields": [<string>]
        }
      },
      "permissions": [
        {
          "role": "anonymous" | "authenticated" | <custom-role>,
          "actions": ["create", "read", "update", "delete", "execute", "*"],
          "fields": {
            "include": [<string>],
            "exclude": [<string>]
          },
          "policy": {
            "database": <string>
          }
        }
      ],
      "cache": {
        "enabled": <boolean>,
        "ttl-seconds": <integer>,
        "level": "L1" | "L1L2" // default: "L1L2"
      },
      "mcp": {
        "dml-tools": <boolean>,       // default: true
        "custom-tool": <boolean>      // stored-procedure only; default: false
      }
    }
  }
}

源(实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name} source 对象 ✔️ 是的 None

实体的数据库源详细信息。

嵌套属性

Parent Property 类型 Required Default
entities.{entity-name}.source object 字符串 ✔️ 是的 None
entities.{entity-name}.source object-description 字符串 ❌ 否 None
entities.{entity-name}.source type 枚举 (table, , viewstored-procedure ✔️ 是的 None
entities.{entity-name}.source key-fields 字符串数组 ❌ 不* None
entities.{entity-name}.source parameters 数组或对象 ❌ 不** None

* key-fields仅在使用数组且type未使用数组时才viewfields是必需的。 该值表示主键。

警告

key-fields 属性在 DAB 2.0 中已弃用。 fields请改用primary-key: true数组。 架构强制实施该 fields 架构,并且 key-fields 不能在同一实体上共存。

** parameters仅当为type具有默认值的参数时才stored-procedure需要 。 推断参数的数据类型。 可以省略不带默认值的参数。

object-description 是基础数据库对象的可选可读说明。 此值在 MCP 工具发现过程中浮出水面,帮助 AI 代理了解实体的目的。

Tip

如果对象属于 dbo 架构,则指定架构是可选的。 此外,如果需要,可以使用对象名称周围的方括号(例如, dbo.Users 与) [dbo].[Users]

Format

{
  "entities": {
    "{entity-name}": {
      "source": {
        "object": <string>,
        "object-description": <string>,
        "type": <"view" | "stored-procedure" | "table">,
        "key-fields": [ <string> ], // DEPRECATED: use fields[].primary-key
        "parameters": [ // array format (preferred)
          {
            "name": "<parameter-name>",
            "required": <boolean>,
            "default": <value>,
            "description": "<string>"
          }
        ]
      }
    }
  }
}

参数数组格式

在 DAB 2.0 预览版中, parameters 支持具有更丰富的元数据的结构化数组格式。 每个参数都是具有以下属性的对象:

Property 类型 Required Description
name 字符串 ✔️ 是的 参数名称(不含 @ 前缀)
required boolean ❌ 否 参数是必需参数(true)还是可选(false
default 任意 ❌ 否 未提供参数时使用的默认值
description 字符串 ❌ 否 参数的可读说明

示例(数组格式 - 首选)

{
  "entities": {
    "GetBookById": {
      "source": {
        "type": "stored-procedure",
        "object": "dbo.get_book_by_id",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "default": null,
            "description": "The unique identifier of the book"
          }
        ]
      }
    }
  }
}

警告

DAB 2.0 中已弃用(例如,parameters)的字典格式{ "id": 0 }。 使用前面的数组格式。 旧格式仍可接受以实现向后兼容性,但在将来的版本中将被删除。

Note

本节中描述的数据 API 生成器 2.0 功能目前处于预览状态,在正式发布之前可能会更改。 有关详细信息,请参阅 版本 2.0 中的新增功能。

权限(实体名称实体)

Parent Property 类型 Required Default
entities.permissions role 字符串 ✔️ 是的 None

指定权限应用于的角色名称。 使用标识提供者中定义的系统角色(AnonymousAuthenticated)或自定义角色。

Tip

有关角色评估、系统角色和 X-MS-API-ROLE 标头的详细信息,请参阅 授权概述

Format

{
  "entities": {
    "{entity-name}": {
      "permissions": [
        {
          "role": <"Anonymous" | "Authenticated" | "custom-role">,
          "actions": [ <string> ]
        }
      ]
    }
  }
}

Example

{
  "entities": {
    "User": {
      "permissions": [
        {
          "role": "reader",
          "actions": ["read"]
        }
      ]
    }
  }
}

角色继承

DAB 2.0 引入了实体权限的角色继承。 如果未为实体显式配置角色,则它使用以下链从更广泛的角色继承权限:

named-role → authenticated → anonymous
  • 如果未 authenticated 为实体配置,则它继承自 anonymous
  • 如果未配置命名角色,则它继承自authenticated或不存在anonymousauthenticated

这意味着你可以定义权限 anonymous 一次,并且每个更广泛的角色会自动获得相同的访问权限,无需重复。

Note

本节中描述的数据 API 生成器 2.0 功能目前处于预览状态,在正式发布之前可能会更改。 有关详细信息,请参阅 版本 2.0 中的新增功能。

Example

{
  "entities": {
    "Book": {
      "source": "dbo.books",
      "permissions": [
        { "role": "anonymous", "actions": [ "read" ] }
      ]
    }
  }
}

使用此配置,anonymousauthenticated以及任何未配置的命名角色都可以读取Book。 用于 dab configure --show-effective-permissions 在应用继承后查看每个实体的解析权限。

作(字符串数组权限实体名称实体)

Parent Property 类型 Required Default
entities.permissions actions oneOf [string, array] ✔️ 是的 None

一个字符串数组,详细说明关联角色允许的作。

Action SQL作
* 所有作
create 插入一个或多个* 行
read 选择一行或多行
update 修改一个或多个* 行
delete 删除一个或多个* 行
execute 运行存储过程

* GraphQL 目前仅支持多个作。

Note

对于存储过程,通配符(*)操作仅扩展到 execute 操作。 对于表和视图,它扩展到 createreadupdatedelete

Format

{
  "entities": {
    "{entity-name}": {
      "permissions": [
        {
          "actions": [ <string> ]
        }
      ]
    }
  }
}

Example

{
  "entities": {
    "{entity-name}": {
      "permissions": [
        {
          "actions": [ "*" ] // equivalent to create, read, update, delete
        }
      ]
    }
  }
}

备用格式(仅字符串,当 type=stored-procedure

{
  "entities": {
    "{entity-name}": {
      "permissions": [
        {
          "actions": <string>
        }
      ]
    }
  }
}

Example

{
  "entities": {
    "{entity-name}": {
      "permissions": [
        {
          "actions": "*" // equivalent to execute
        }
      ]
    }
  }
}

作(对象数组权限实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name}.permissions actions 字符串数组 ✔️ 是的 None

一个对象数组,详细说明了关联角色允许的作。

Note

对于存储过程,通配符(*)操作仅扩展到 execute。 对于表/视图,它扩展到 createreadupdatedelete

嵌套属性

Parent Property 类型 Required Default
entities.{entity-name}.permissions.actions[] action 字符串 ✔️ 是的 None
entities.{entity-name}.permissions.actions[] fields 对象 ❌ 否 None
entities.{entity-name}.permissions.actions[] policy 对象 ❌ 否 None
entities.{entity-name}.permissions.actions[].policy database 字符串 ✔️ 是的 None

Format

{
  "entities": {
    "{entity-name}": {
      "permissions": [
        {
          "role": <string>,
          "actions": [
            {
              "action": <string>,
              "fields": <array of strings>,
              "policy": <object>
            }
          ]
        }
      ]
    }
  }

Example

这会授予readauditorUser实体的权限,并具有字段和策略限制。

{
  "entities": {
    "User": {
      "permissions": [
        {
          "role": "auditor",
          "actions": [
            {
              "action": "read",
              "fields": {
                "include": ["*"],
                "exclude": ["last_login"]
              },
              "policy": {
                "database": "@item.IsAdmin eq false"
              }
            }
          ]
        }
      ]
    }
  }
}

策略说明

数据库策略使用 OData 样式谓词筛选查询结果。 用于 @item.<field> 引用实体字段并 @claims.<type> 注入经过身份验证的用户声明。

方面 详细信息
Syntax OData 谓词(eq、、neandor、) gtlt
字段参考 @item.<field> (如果适用)使用映射的名称)
声明引用 @claims.<claimType>
支持的操作 readupdatedelete
不支持 createexecute

Tip

有关数据库策略(包括声明替换和故障排除)的综合指南,请参阅 “配置数据库策略”。

类型(GraphQL 实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name}.graphql type 对象 ❌ 否 {entity-name}

设置 GraphQL 架构中实体的命名约定。

Format

{
  "entities": {
    "{entity-name}": {
      "graphql": {
        "type": {
          "singular": "<string>",
          "plural": "<string>"
        }
      }
    }
  }
}

嵌套属性

Parent Property Required 类型 Default
entities.{entity-name}.graphql.type singular ✔️ 是的* 字符串 None
entities.{entity-name}.graphql.type plural ❌ 否 字符串 N/A (默认值为单一值)

* singular 在指定为对象时 type 是必需的。 当 type 为纯字符串时,该字符串用作单一名称。

Example

Configuration

{
  "entities": {
    "User": {
      "graphql": {
        "type": {
          "singular": "User",
          "plural": "Users"
        }
      }
    }
  }
}

GraphQL 查询

{
  Users {
    items {
      id
      name
      age
      isAdmin
    }
  }
}

GraphQL 响应

{
  "data": {
    "Users": {
      "items": [
        {
          "id": 1,
          "name": "Alice",
          "age": 30,
          "isAdmin": true
        },
        {
          "id": 2,
          "name": "Bob",
          "age": 25,
          "isAdmin": false
        }
        // ...
      ]
    }
  }
}

作(GraphQL 实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name}.graphql operation 枚举字符串 ❌ 否 mutation

指定作是否stored-procedure显示在作的下方QueryMutation

Note

{entity-name}.type 设置为 stored-procedure时,将自动创建新的 GraphQL 类型 executeXXX。 此属性 operation 控制此类型放置在 GraphQL 架构中的位置。 没有功能影响,只是架构卫生。

Format

{
  "entities": {
    "{entity-name}": {
      "graphql": {
        "operation": "query" | "mutation"
      }
    }
  }
}

示例:作

何时 operation 设置为 query

type Query {
  executeGetUserDetails(userId: Int!): GetUserDetailsResponse
}

何时 operation 设置为 mutation

type Mutation {
  executeGetUserDetails(userId: Int!): GetUserDetailsResponse
}

已启用 (GraphQL 实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name}.graphql enabled boolean ❌ 否 True

允许开发人员选择性地将实体包含在 GraphQL 架构中。

Format

{
  "entities": {
    "{entity-name}": {
      "graphql": {
        "enabled": <true> (default) | <false>
      }
    }
  }
}

REST (实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name}.rest enabled boolean ❌ 否 True
entities.rest path 字符串 ❌ 否 /{entity-name}
entities.{entity-name}.rest methods 字符串数组 ❌ 不* POST

* 该 methods 属性仅适用于 stored-procedure 终结点。

Note

本节中描述的数据 API 生成器 2.0 功能目前处于预览状态,在正式发布之前可能会更改。 有关详细信息,请参阅 版本 2.0 中的新增功能。

Format

{
  "entities": {
    "{entity-name}": {
      "rest": {
        "enabled": <true> (default) | <false>,
        "path": <string; default: "{entity-name}">
      }
    }
  }
}

说明(实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name} description 字符串 ❌ 否 None

实体的可选可读说明。 此值显示在生成的 API 文档中,并在 GraphQL 架构中作为注释显示。

Note

本节中描述的数据 API 生成器 2.0 功能目前处于预览状态,在正式发布之前可能会更改。 有关详细信息,请参阅 版本 2.0 中的新增功能。

Format

{
  "entities": {
    "{entity-name}": {
      "description": "<string>"
    }
  }
}

Example

{
  "entities": {
    "Book": {
      "description": "Represents a book in the catalog with title, author, and pricing information.",
      "source": {
        "object": "dbo.books",
        "type": "table"
      }
    }
  }
}

字段(实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name} fields 数组 ❌ 否 None

定义各个数据库字段的元数据,包括别名、说明和主键指定。 数组 fields 在单个统一结构中替换 mappings (通过 alias 属性)和 source.key-fields (通过 primary-key 属性)。

Note

本节中描述的数据 API 生成器 2.0 功能目前处于预览状态,在正式发布之前可能会更改。 有关详细信息,请参阅 版本 2.0 中的新增功能。

嵌套属性

Parent Property 类型 Required Default
entities.{entity-name}.fields[] name 字符串 ✔️ 是的 None
entities.{entity-name}.fields[] alias 字符串 ❌ 否 None
entities.{entity-name}.fields[] description 字符串 ❌ 否 None
entities.{entity-name}.fields[] primary-key boolean ❌ 否 false

Format

{
  "entities": {
    "{entity-name}": {
      "fields": [
        {
          "name": "<database-field-name>",
          "alias": "<api-exposed-name>",
          "description": "<string>",
          "primary-key": <boolean>
        }
      ]
    }
  }
}

Example

{
  "entities": {
    "Book": {
      "source": {
        "object": "dbo.books",
        "type": "table"
      },
      "fields": [
        {
          "name": "id",
          "description": "Unique book identifier",
          "primary-key": true
        },
        {
          "name": "sku_title",
          "alias": "title",
          "description": "The display title of the book"
        },
        {
          "name": "sku_status",
          "alias": "status"
        }
      ]
    }
  }
}

在此示例中,id被指定为主键(替换需要),source.key-fieldssku_titlesku_status别名为titlestatus(替换需要)。mappings

Important

架构强制 fields 实施无法与 mappings 同一实体共存或 source.key-fields 位于同一实体上。 fields迁移到并删除已弃用的属性。

映射(实体名称实体)

警告

mappings 属性在 DAB 2.0 中已弃用。 请改用带 fields 属性的 alias 数组。 架构强制实施该 fields 架构,并且 mappings 不能在同一实体上共存。

Parent Property 类型 Required Default
entities.{entity-name} mappings 对象 ❌ 否 None

为数据库对象字段启用自定义别名或公开的名称。

Important

对于启用了 GraphQL 的实体,配置的公开名称必须满足 GraphQL 名称要求

Format

{
  "entities": {
    "{entity-name}": {
      "mappings": {
        "<field-1-name>": "<field-1-alias>",
        "<field-2-name>": "<field-2-alias>",
        "<field-3-name>": "<field-3-alias>"
      }
    }
  }
}

Examples

数据库表

CREATE TABLE Books
(
  id INT,
  sku_title VARCHAR(50),
  sku_status VARCHAR(50),
)

Configuration

{
  "entities": {
    "Books": {
      ...
      "mappings": {
        "sku_title": "title",
        "sku_status": "status"
      }
    }
  }
}

缓存(实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name} cache 对象 ❌ 否 None

启用和配置实体的缓存。

嵌套属性

Parent Property 类型 Required Default
entities.{entity-name}.cache enabled boolean ❌ 否 False
entities.{entity-name}.cache ttl-seconds 整数 ❌ 否 -
entities.{entity-name}.cache level 枚举 (L1 | L1L2 ❌ 否 L1L2

Format

{
  "entities": {
    "{entity-name}": {
      "cache": {
        "enabled": <true> (default) | <false>,
        "ttl-seconds": <integer; default: 5>,
        "level": <"L1" | "L1L2"> (default: "L1L2")
      }
    }
  }
}

level 属性控制使用哪些缓存层:

价值 Description
L1 仅内存中缓存。 最快,但不跨实例共享。
L1L2 内存中缓存加上分布式 (Redis) 缓存。 跨横向扩展实例共享。 违约。

Note

本节中描述的数据 API 生成器 2.0 功能目前处于预览状态,在正式发布之前可能会更改。 有关详细信息,请参阅 版本 2.0 中的新增功能。

Note

如果未指定, ttl-seconds 则继承设置的 runtime.cache全局值。

Example

{
  "entities": {
    "Author": {
      "cache": {
        "enabled": true,
        "ttl-seconds": 30,
        "level": "L1"
      }
    }
  }
}

关系(实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name} relationships 对象 ❌ 否 None

配置 GraphQL 实体与其他公开实体的关系。 有关详细信息,请参阅 数据 API 生成器关系细分

Note

relationship-name每个关系的属性在该实体的所有关系中必须是唯一的。

嵌套属性

这些属性在不同的组合中使用,具体取决于关系基数。

Parent Property 类型 Required Default
entities.{entity-name}.relationships cardinality 字符串 ✔️ 是的 None
entities.{entity-name}.relationships target.entity 字符串 ✔️ 是的 None
entities.{entity-name}.relationships target.fields 字符串数组 ❌ 否 None
entities.{entity-name}.relationships source.fields 字符串数组 ❌ 否 None
entities.{entity-name}.relationships linking.object 字符串 ❌ 否 None
entities.{entity-name}.relationships linking.source.fields 字符串数组 ❌ 否 None
entities.{entity-name}.relationships linking.target.fields 字符串数组 ❌ 否 None

Format

{
  "entities": {
    "{entity-name}": {
      "relationships": {
        "<relationship-name>": {
          "cardinality": "one" | "many",
          "target.entity": "<string>",
          "source.fields": ["<string>"],
          "target.fields": ["<string>"],
          "linking.object": "<string>",
          "linking.source.fields": ["<string>"],
          "linking.target.fields": ["<string>"]
        }
      }
    }
  }
}
Relationship Cardinality Example
one-to-many many 一个类别实体可以与多个待办事项实体关联
many-to-one one 许多待办事项实体可能与一个类别实体相关
many-to-many many 一个待办事项实体可以与多个用户实体关联,一个用户实体可以与多个待办实体关联

示例:一对一基数

每个 Profile 都与一个 User完全相关,每个都 User 只有一个相关 Profile

{
  "entities": {
    "User": {
      "relationships": {
        "user_profile": {
          "cardinality": "one",
          "target.entity": "Profile",
          "source.fields": [ "id" ],
          "target.fields": [ "user_id" ]
        }
      }
    },
    "Profile": {
      ...
    }
  }
}

GraphQL 架构

type User
{
  id: Int!
  ...
  profile: Profile
}

Command-line

dab update User \
  --relationship profile \
  --target.entity Profile \
  --cardinality one \
  --relationship.fields "id:user_id"

示例:一对多基数

A Category 可以有一个或多个相关 Book 实体,而每个实体 Book 可以有一个相关 Category实体。

{
  "entities": {
    "Book": {
      ...
    },
    "Category": {
      "relationships": {
        "category_books": {
          "cardinality": "many",
          "target.entity": "Book",
          "source.fields": [ "id" ],
          "target.fields": [ "category_id" ]
        }
      }
    }
  }
}

GraphQL 架构

type Category
{
  id: Int!
  ...
  books: [BookConnection]!
}

命令行

dab update Category \
  --relationship category_books \
  --target.entity Book \
  --cardinality many \
  --relationship.fields "id:category_id"

示例:多对一基数

许多 Book 实体可以有一个相关 Category项,而一 Category 个实体可以有一个或多个相关 Book 条目。

{
  "entities": {
    "Book": {
      "relationships": {
        "books_category": {
          "cardinality": "one",
          "target.entity": "Category",
          "source.fields": [ "category_id" ],
          "target.fields": [ "id" ]
        }
      },
      "Category": {
        ...
      }
    }
  }
}

GraphQL 架构

type Book
{
  id: Int!
  ...
  category: Category
}

命令行

dab update Book \
  --relationship books_category \
  --target.entity "Category" \
  --cardinality one \
  --relationship.fields "category_id:id"

示例:多对多基数

许多 Book 实体可以具有许多相关 Author 实体,而许多 Author 实体可以具有许多相关 Book 条目。

Note

此关系可与第三个表一起实现, dbo.books_authors我们称之为 链接对象

{
  "entities": {
    "Book": {
      "relationships": {
        ...,
        "books_authors": {
          "cardinality": "many",
          "target.entity": "Author",
          "source.fields": [ "id" ],
          "target.fields": [ "id" ],
          "linking.object": "dbo.books_authors",
          "linking.source.fields": [ "book_id" ],
          "linking.target.fields": [ "author_id" ]
        }
      },
      "Category": {
        ...
      },
      "Author": {
        ...
      }
    }
  }
}

GraphQL 架构

type Book
{
  id: Int!
  ...
  authors: [AuthorConnection]!
}

type Author
{
  id: Int!
  ...
  books: [BookConnection]!
}

命令行

dab update Book \
  --relationship books_authors \
  --target.entity "Author" \
  --cardinality many \
  --relationship.fields "id:id" \
  --linking.object "dbo.books_authors" \
  --linking.source.fields "book_id" \
  --linking.target.fields "author_id"

运行状况(实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name} health 对象 ❌ 否 None

启用和配置实体的运行状况检查。

嵌套属性

Parent Property 类型 Required Default
entities.{entity-name}.health enabled boolean ❌ 否 true
entities.{entity-name}.health first 整数 ❌ 否 100
entities.{entity-name}.health threshold-ms 整数 ❌ 否 1000

Example

{
  "entities": {
    "Book": {
      "health": {
        "enabled": true,
        "first": 3,
        "threshold-ms": 500
      }
    }
  }
}

Note

该值 first 必须小于或等于 runtime.pagination.max-page-size 设置。 较小的值有助于更快地完成运行状况检查。

Important

存储过程会自动从实体运行状况检查中排除,因为它们需要参数,可能不是确定性的。

MCP (实体名称实体)

Parent Property 类型 Required Default
entities.{entity-name} mcp 对象 ❌ 否 在省略时默认启用

控制实体的 MCP 参与。 全局启用 MCP 时,实体默认参与。 使用此属性可以选择退出或为存储过程实体启用自定义 MCP 工具。

Note

本节中描述的数据 API 生成器 2.0 功能目前处于预览状态,在正式发布之前可能会更改。 有关详细信息,请参阅 版本 2.0 中的新增功能。

对象格式

使用对象格式进行精细控制:

Parent Property 类型 Required Default
entities.{entity-name}.mcp dml-tools boolean ❌ 否 true
entities.{entity-name}.mcp custom-tool boolean ❌ 否 false
{
  "entities": {
    "Book": {
      "mcp": {
        "dml-tools": true
      }
    }
  }
}

自定义工具(仅存储过程)

对于存储过程实体,设置为custom-tooltrue将过程注册为命名 MCP 工具:

{
  "entities": {
    "GetBookById": {
      "source": {
        "type": "stored-procedure",
        "object": "dbo.get_book_by_id"
      },
      "mcp": {
        "custom-tool": true
      },
      "permissions": [
        {
          "role": "anonymous",
          "actions": ["execute"]
        }
      ]
    }
  }
}

Important

custom-tool 属性仅适用于存储过程实体。 在表或视图实体上设置它会导致配置错误。

CLI 示例

dab add Book --source books --permissions "anonymous:*" --mcp.dml-tools true
dab add GetBookById --source dbo.get_book_by_id --source.type stored-procedure --permissions "anonymous:execute" --mcp.custom-tool true