Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Tambahkan definisi entitas baru ke file konfigurasi penyusun API Data yang ada. Anda harus sudah memiliki konfigurasi yang dibuat dengan dab init. Gunakan dab update untuk memodifikasi entitas setelah pembuatan.
Petunjuk / Saran
Gunakan dab add untuk membuat entitas baru, dan dab update untuk mengembangkannya. Pemetakan ulang nama bidang (--map) hanya tersedia di update, bukan di add.
Syntax
dab add <entity-name> [options]
Sekilas
| Option | Ringkasan |
|---|---|
<entity-name> |
Argumen posisi yang diperlukan. Nama entitas logis. |
-c, --config |
Jalur file konfigurasi. Bawaan dab-config.json. |
--cache.enabled |
Aktifkan/nonaktifkan penembolokan untuk entitas. |
--cache.ttl |
Cache time-to-live dalam hitungan detik. |
--description |
Deskripsi bentuk bebas untuk entitas. |
--fields.exclude |
Bidang yang dikecualikan yang dipisahkan koma. |
--fields.include |
Bidang yang diizinkan dipisahkan koma (* = semua). |
--graphql |
Paparan GraphQL: false, true, singular, atau singular:plural. |
--graphql.operation |
Prosedur tersimpan saja.
query atau mutation (mutasi default). |
--permissions |
Dibutuhkan. Satu atau beberapa role:actions pasangan. Berulang. |
--policy-database |
Filter gaya OData diterapkan dalam kueri DB. |
--policy-request |
Kebijakan permintaan dievaluasi sebelum panggilan DB. |
--rest |
Paparan REST: false, true, atau rute kustom. |
--rest.methods |
Prosedur tersimpan saja. Kata kerja HTTP yang diizinkan. POST default. |
-s, --source |
Dibutuhkan. Nama objek database (tabel, tampilan, atau prosedur tersimpan). |
--source.key-fields |
Diperlukan untuk tampilan atau ketika PK tidak disimpulkan. Tidak diizinkan untuk proc. |
--source.params |
Prosedur tersimpan saja. Nilai parameter default. |
--source.type |
Jenis sumber: table, view, stored-procedure (tabel default). |
<entity-name>
Nama logis entitas dalam konfigurasi. Peka huruf besar/kecil.
Example
dab add Book --source dbo.Books --permissions "anonymous:read"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": {
"type": "table",
"object": "dbo.Books"
},
"permissions": [
{
"role": "anonymous",
"actions": [ "read" ]
}
]
}
}
}
-c, --config
Jalur file konfigurasi. Defaultnya adalah dab-config.json.
Example
dab add Book --config ./dab-config.mssql.json --source dbo.Books --permissions "anonymous:read"
--cache.enabled
Mengaktifkan atau menonaktifkan penembolokan.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --cache.enabled true
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": {
"type": "table",
"object": "dbo.Books"
},
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"cache": {
"enabled": true
}
}
}
}
--cache.ttl
Cache time-to-live dalam hitungan detik.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --cache.ttl 300
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": {
"type": "table",
"object": "dbo.Books"
},
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"cache": {
"ttl-seconds": 300
}
}
}
}
--description
Deskripsi teks bebas entitas.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --description "Entity for managing book inventory"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": {
"type": "table",
"object": "dbo.Books"
},
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"description": "Entity for managing book inventory"
}
}
}
--fields.exclude
Daftar bidang yang dipisahkan koma untuk dikecualikan.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --fields.exclude "internal_flag,secret_note"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": { "type": "table", "object": "dbo.Books" },
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"graphql": {
"fields": {
"exclude": [ "internal_flag", "secret_note" ]
}
}
}
}
}
--fields.include
Daftar bidang yang dipisahkan koma untuk diekspos.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --fields.include "id,title,price"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": { "type": "table", "object": "dbo.Books" },
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"graphql": {
"fields": {
"include": [ "id", "title", "price" ]
}
}
}
}
}
--graphql
Mengontrol paparan GraphQL.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --graphql book:books
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": { "type": "table", "object": "dbo.Books" },
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"graphql": {
"singular": "book",
"plural": "books"
}
}
}
}
--graphql.operation
Prosedur tersimpan saja. Jenis operasi GraphQL. Defaultnya adalah mutation.
Example
dab add BookProc --source dbo.MyProc --source.type stored-procedure --permissions "admin:execute" --graphql.operation query
Konfigurasi yang dihasilkan
{
"entities": {
"BookProc": {
"source": { "type": "stored-procedure", "object": "dbo.MyProc" },
"permissions": [
{ "role": "admin", "actions": [ "execute" ] }
],
"graphql": {
"operation": "query"
}
}
}
}
--permissions
Mendefinisikan pasangan peran→actions. Gunakan bendera berulang untuk beberapa peran.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --permissions "authenticated:create,read,update,delete"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": { "type": "table", "object": "dbo.Books" },
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] },
{ "role": "authenticated", "actions": [ "create", "read", "update", "delete" ] }
]
}
}
}
--policy-database
Kebijakan tingkat database.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --policy-database "region eq 'US'"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": { "type": "table", "object": "dbo.Books" },
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"policies": {
"database": "region eq 'US'"
}
}
}
}
--policy-request
Kebijakan tingkat permintaan.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --policy-request "@claims.role == 'admin'"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": { "type": "table", "object": "dbo.Books" },
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"policies": {
"request": "@claims.role == 'admin'"
}
}
}
}
--rest
Mengontrol paparan REST.
Example
dab add Book --source dbo.Books --permissions "anonymous:read" --rest BooksApi
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": { "type": "table", "object": "dbo.Books" },
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
],
"rest": {
"path": "BooksApi"
}
}
}
}
--rest.methods
Prosedur tersimpan saja. Kata kerja HTTP diizinkan untuk eksekusi. Default ke POST. Diabaikan untuk tabel/tampilan.
Example
dab add BookProc --source dbo.MyProc --source.type stored-procedure --permissions "admin:execute" --rest true --rest.methods GET,POST
Konfigurasi yang dihasilkan
{
"entities": {
"BookProc": {
"source": { "type": "stored-procedure", "object": "dbo.MyProc" },
"permissions": [
{ "role": "admin", "actions": [ "execute" ] }
],
"rest": {
"path": "BookProc",
"methods": [ "GET", "POST" ]
}
}
}
}
-s, --source
Dibutuhkan. Nama objek database: tabel, tampilan, atau prosedur tersimpan.
Example
dab add Book --source dbo.Books --permissions "anonymous:read"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": {
"type": "table",
"object": "dbo.Books"
},
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
]
}
}
}
--source.key-fields
Diperlukan untuk tampilan. Juga diperlukan untuk tabel tanpa PK yang dapat disimpulkan. Tidak diizinkan untuk prosedur tersimpan.
Example
dab add BookView --source dbo.MyView --source.type view --source.key-fields "id,region" --permissions "anonymous:read"
Konfigurasi yang dihasilkan
{
"entities": {
"BookView": {
"source": {
"type": "view",
"object": "dbo.MyView",
"keyFields": [ "id", "region" ]
},
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
]
}
}
}
--source.params
Prosedur tersimpan saja. Pasangan yang dipisahkan name:value koma. Tidak diperbolehkan untuk tabel atau tampilan.
Example
dab add BookProc --source dbo.MyProc --source.type stored-procedure --source.params "year:2024,active:true" --permissions "admin:execute"
Konfigurasi yang dihasilkan
{
"entities": {
"BookProc": {
"source": {
"type": "stored-procedure",
"object": "dbo.MyProc",
"params": {
"year": 2024,
"active": true
}
},
"permissions": [
{ "role": "admin", "actions": [ "execute" ] }
]
}
}
}
--source.type
Jenis objek database. Standar: table.
Example
dab add Book --source dbo.Books --source.type table --permissions "anonymous:read"
Konfigurasi yang dihasilkan
{
"entities": {
"Book": {
"source": {
"type": "table",
"object": "dbo.Books"
},
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] }
]
}
}
}