データベース エンティティの構成設定。
Health
Property | Description |
---|---|
entities.entity-name.health.enabled |
エンティティの正常性チェック エンドポイントを有効にします |
entities.entity-name.health.first |
正常性チェック クエリで返される行の数 |
entities.entity-name.health.threshold-ms |
正常性チェック クエリの最大期間 (ミリ秒単位) |
Source
Property | Description |
---|---|
entities.entity-name.source.type |
オブジェクトの種類: table 、 view 、または stored-procedure |
entities.entity-name.source.object |
データベース オブジェクトの名前 |
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 、 post 、 put 、 patch 、 delete |
GraphQL
Property | Description |
---|---|
entities.entity-name.graphql.type |
singular を使用して名前またはオブジェクトを入力します。plural |
entities.entity-name.graphql.operation |
操作の種類: query または mutation |
entities.entity-name.graphql.enabled |
このエンティティの GraphQL を有効にします |
Permissions
Property | Description |
---|---|
entities.entity-name.permissions[].role |
ロール名の文字列 |
entities.entity-name.permissions[].actions |
1 つ以上: create 、 read 、 update 、 delete 、 execute |
Relationships
Property | Description |
---|---|
entities.entity-name.relationships.relationship-name.cardinality |
one または many |
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 |
キャッシュの有効期間 (秒単位) |
Format overview
{
"entities": {
"{entity-name}": {
"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>,
"type": "view" | "stored-procedure" | "table",
"key-fields": [<string>], // primary keys for the view
"parameters": { // only for stored-procedure
"<parameter-name>": <string | number | boolean>,
"<parameter-name>": <string | number | boolean>
}
},
"mappings": {
"<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>
}
}
]
}
}
}
ソース (エンティティ名エンティティ)
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name} |
source |
オブジェクト | ✔️ Yes | None |
エンティティのデータベース ソースの詳細。
Nested properties
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name}.source |
object |
文字列 | ✔️ Yes | None |
entities.{entity-name}.source |
type |
enum (table 、 view 、 stored-procedure ) |
✔️ Yes | None |
entities.{entity-name}.source |
key-fields |
string array | ✔️ Yes* | None |
entities.{entity-name}.source |
parameters |
オブジェクト | ✔️ Yes** | None |
-
key-fields
は、type
がview
されている場合にのみ必要です。 値は主キーを表します。
**
parameters
は、 type
が stored-procedure
されている場合にのみ必要です。 省略可能なパラメーターは省略できます。
Tip
オブジェクトが dbo
スキーマに属している場合、スキーマの指定は省略可能です。 さらに、必要に応じて、オブジェクト名の角かっこ ( dbo.Users
と [dbo].[Users]
など) を使用できます。
サポートされているパラメーター データ型:
-
string
—ANSI と Unicode が含まれます。JSON/Date/DateTime 型にも使用されます -
number
—整数と 10 進数を含む -
boolean
—true
またはfalse
Format
{
"entities": {
"{entity-name}": {
"source": {
"object": <string>,
"type": <"view" | "stored-procedure" | "table">,
"key-fields": [ <string> ], // primary keys of the view
"parameters": { // only for stored-procedure
"<parameter-name-1>": <string | number | boolean>,
"<parameter-name-2>": <string | number | boolean>
}
}
}
}
}
アクセス許可 (エンティティ名エンティティ)
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.permissions |
role |
文字列 | ✔️ Yes | None |
アクセス許可が適用されるロールの名前を指定する文字列。
Format
{
"entities": {
"{entity-name}": {
"permissions": [
{
"role": <"anonymous" | "authenticated" | "custom-role">
}
]
}
}
}
Example
この例では、User
エンティティに対するread
アクセス許可のみを持つロール custom-role
を定義します。
{
"entities": {
"User": {
"permissions": [
{
"role": "custom-role",
"actions": ["read"]
}
]
}
}
}
Usage examples
GET https://localhost:5001/api/User
Authorization: Bearer <your_access_token>
X-MS-API-ROLE: custom-role
アクション (string-array Permissions エンティティ名エンティティ)
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.permissions |
actions |
oneOf [string, array] | ✔️ Yes | None |
関連付けられているロールに対して許可される操作の詳細を示す文字列配列。
Action | SQL Operation |
---|---|
* |
All actions |
create |
1 つ以上の * 行を挿入する |
read |
1 つ以上の行を選択する |
update |
1 つ以上の * 行を変更する |
delete |
1 つ以上の * 行を削除する |
execute |
ストアド プロシージャを実行する |
* 現在、複数の操作は GraphQL でのみサポートされています。
Note
ストアド プロシージャの場合、ワイルドカード (*
) アクションは execute
アクションにのみ展開されます。 テーブルとビューの場合、create
、read
、update
、および delete
に展開されます。
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
}
]
}
}
}
アクション (object-array Permissions エンティティ名エンティティ)
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name}.permissions |
actions |
string array | ✔️ Yes | None |
関連付けられたロールに対して許可される操作の詳細を示すオブジェクト配列。
Note
ストアド プロシージャの場合、ワイルドカード (*
) アクションは execute
にのみ拡張されます。 テーブル/ビューの場合は、create
、read
、update
、および delete
に展開されます。
Nested properties
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name}.permissions.actions[] |
action |
文字列 | ✔️ Yes | None |
entities.{entity-name}.permissions.actions[] |
fields |
オブジェクト | ❌ いいえ | None |
entities.{entity-name}.permissions.actions[] |
policy |
オブジェクト | ❌ いいえ | None |
entities.{entity-name}.permissions.actions[].policy |
database |
文字列 | ✔️ Yes | None |
Format
{
"entities": {
"{entity-name}": {
"permissions": [
{
"role": <string>,
"actions": [
{
"action": <string>,
"fields": <array of strings>,
"policy": <object>
}
]
}
]
}
}
Example
これによりread
フィールドとポリシーの制限を使用して、User
エンティティにauditor
するアクセス許可が付与されます。
{
"entities": {
"User": {
"permissions": [
{
"role": "auditor",
"actions": [
{
"action": "read",
"fields": {
"include": ["*"],
"exclude": ["last_login"]
},
"policy": {
"database": "@item.IsAdmin eq false"
}
}
]
}
]
}
}
}
Policy notes
- ポリシーでは、
eq
などの OData 演算子がサポートされます。 - ポリシーでは、
and
とor
を使用した複合述語がサポートされます。 - アクション (
create
、read
、update
、delete
) でのみサポートされます。 (execute
ではありません) - ポリシーは結果をフィルター処理しますが、データベースでのクエリの実行を妨げることはありません。
- フィールドがマップされている場合は、フィールドエイリアスを使用する必要があります。
型 (GraphQL エンティティ名エンティティ)
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name}.graphql |
type |
オブジェクト | ❌ いいえ | {entity-name} |
GraphQL スキーマ内のエンティティの名前付け規則を設定します。
Format
{
"entities": {
"{entity-name}": {
"graphql": {
"type": {
"singular": "<string>",
"plural": "<string>"
}
}
}
}
}
Nested properties
Parent | Property | Required | タイプ | Default |
---|---|---|---|---|
entities.{entity-name}.graphql.type |
singular |
❌ いいえ | 文字列 | None |
entities.{entity-name}.graphql.type |
plural |
❌ いいえ | 文字列 | N/A (既定値は単数形) |
Example
Configuration
{
"entities": {
"User": {
"graphql": {
"type": {
"singular": "User",
"plural": "Users"
}
}
}
}
}
GraphQL query
{
Users {
items {
id
name
age
isAdmin
}
}
}
GraphQL response
{
"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 |
enum string | ❌ いいえ | mutation |
Query
またはMutation
の下にstored-procedure
操作を表示するかどうかを指定します。
Note
{entity-name}.type
を stored-procedure
に設定すると、新しい GraphQL 型executeXXX
が自動的に作成されます。 この operation
プロパティは、この型が GraphQL スキーマに配置される場所を制御します。 機能上の影響はなく、スキーマの検疫に過ぎません。
Format
{
"entities": {
"{entity-name}": {
"graphql": {
"operation": "query" | "mutation"
}
}
}
}
Example: operation
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 |
string array | ❌ いいえ* | POST |
* methods
プロパティは、 stored-procedure
エンドポイント専用です。
Format
{
"entities": {
"{entity-name}": {
"rest": {
"enabled": <true> (default) | <false>,
"path": <string; default: "{entity-name}">
}
}
}
}
マッピング (エンティティ名エンティティ)
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
Database Table
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 |
エンティティのキャッシュを有効にして構成します。
Nested properties
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name}.cache |
enabled |
boolean | ❌ いいえ | False |
entities.{entity-name}.cache |
ttl-seconds |
整数 | ❌ いいえ | - |
Format
{
"entities": {
"{entity-name}": {
"cache": {
"enabled": <true> (default) | <false>,
"ttl-seconds": <integer; default: 5>
}
}
}
}
Note
指定しない場合、 ttl-seconds
は runtime.cache
の下に設定されたグローバル値を継承します。
Example
{
"entities": {
"Author": {
"cache": {
"enabled": true,
"ttl-seconds": 30
}
}
}
}
リレーションシップ (エンティティ名エンティティ)
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name} |
relationships |
オブジェクト | ❌ いいえ | None |
GraphQL エンティティを他の公開エンティティと関連付ける方法を構成します。 詳細については、「データ API ビルダーのリレーションシップの内訳
Note
各リレーションシップの relationship-name
プロパティは、そのエンティティのすべてのリレーションシップで一意である必要があります。
Nested properties
これらのプロパティは、リレーションシップのカーディナリティに応じて異なる組み合わせで使用されます。
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name}.relationships |
cardinality |
文字列 | ✔️ Yes | None |
entities.{entity-name}.relationships |
target.entity |
文字列 | ✔️ Yes | None |
entities.{entity-name}.relationships |
target.fields |
string array | ❌ いいえ | None |
entities.{entity-name}.relationships |
source.fields |
string array | ❌ いいえ | None |
entities.{entity-name}.relationships |
linking.object |
文字列 | ❌ いいえ | None |
entities.{entity-name}.relationships |
linking.source.fields |
string array | ❌ いいえ | None |
entities.{entity-name}.relationships |
linking.target.fields |
string array | ❌ いいえ | 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 |
1 つのカテゴリ エンティティは、多くの todo エンティティに関連付けることができます |
many-to-one | one |
多くの todo エンティティは、1 つのカテゴリ エンティティに関連付けることができます |
many-to-many | many |
1 つの todo エンティティは多くのユーザー エンティティに関連付けることができ、1 つのユーザー エンティティは多くの todo エンティティに関連付けることができます |
例: 1 対 1 のカーディナリティ
各 Profile
は正確に 1 つの User
に関連しており、各 User
には 1 つの関連 Profile
があります。
{
"entities": {
"User": {
"relationships": {
"user_profile": {
"cardinality": "one",
"target.entity": "Profile",
"source.fields": [ "id" ],
"target.fields": [ "user_id" ]
}
}
},
"Profile": {
...
}
}
}
GraphQL schema
type User
{
id: Int!
...
profile: Profile
}
Command-line
dab update User \
--relationship profile \
--target.entity Profile \
--cardinality one \
--relationship.fields "id:user_id"
例: 一対多カーディナリティ
Category
には 1 つ以上の関連するBook
エンティティを含めることができますが、各Book
には 1 つの関連するCategory
を含めることができます。
{
"entities": {
"Book": {
...
},
"Category": {
"relationships": {
"category_books": {
"cardinality": "many",
"target.entity": "Book",
"source.fields": [ "id" ],
"target.fields": [ "category_id" ]
}
}
}
}
}
GraphQL schema
type Category
{
id: Int!
...
books: [BookConnection]!
}
Command line
dab update Category \
--relationship category_books \
--target.entity Book \
--cardinality many \
--relationship.fields "id:category_id"
例: 多対一カーディナリティ
多くの Book
エンティティは、1 つの関連する Category
を持つことができますが、 Category
には 1 つ以上の関連する Book
エントリを含めることができます。
{
"entities": {
"Book": {
"relationships": {
"books_category": {
"cardinality": "one",
"target.entity": "Category",
"source.fields": [ "category_id" ],
"target.fields": [ "id" ]
}
},
"Category": {
...
}
}
}
}
GraphQL schema
type Book
{
id: Int!
...
category: Category
}
Command line
dab update Book \
--relationship books_category \
--target.entity "Category" \
--cardinality one \
--relationship.fields "category_id:id"
例: 多対多カーディナリティ
多くの Book
エンティティには多くの関連 Author
エンティティを含めることができますが、多くの Author
エンティティには多くの関連する Book
エントリを含めることができます。
Note
This relationship is possible with a third table, dbo.books_authors
, which we refer to as the linking object.
{
"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 schema
type Book
{
id: Int!
...
authors: [AuthorConnection]!
}
type Author
{
id: Int!
...
books: [BookConnection]!
}
Command line
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 |
エンティティの正常性チェックを有効にして構成します。
Nested properties
Parent | Property | タイプ | Required | Default |
---|---|---|---|---|
entities.{entity-name}.health |
enabled |
boolean | ❌ いいえ | True |
entities.{entity-name}.health |
first |
整数 | ❌ いいえ | 1 |
entities.{entity-name}.health |
threshold-ms |
整数 | ❌ いいえ | 5 |
Format
{
"entities": {
"{entity-name}": {
"health": {
"enabled": true,
"first": 5,
"threshold-ms": 2000
}
}
}
}
Example
{
"entities": {
"Book": {
"health": {
"enabled": true,
"first": 3,
"threshold-ms": 500
}
}
}
}