Firebase CLI ช่วยให้คุณจัดการโปรเจ็กต์ Firebase ในไดเรกทอรีโปรเจ็กต์ในเครื่องที่ควบคุมเวอร์ชันได้ ซึ่งรวมถึงData Connect บริการในโปรเจ็กต์ของคุณ ตัวเชื่อมต่อสำหรับบริการเหล่านั้น และทรัพยากรต่างๆ เช่น สคีมา แหล่งที่มาของคําค้นหาและการเปลี่ยนแปลงสําหรับตัวเชื่อมต่อแต่ละรายการ นอกจากนี้ CLI ยังช่วยให้คุณ ติดตั้งและใช้งานโปรแกรมจำลอง Firebase Data Connect ได้ด้วย CLI เป็นทางเลือกที่มีประสิทธิภาพแทนการทำงานในFirebaseคอนโซล
ดูวิธีการติดตั้งFirebaseการทดลอง CLI สำหรับ โปรแกรมตัวอย่างแบบส่วนตัวและคำสั่ง CLI ที่เกี่ยวข้องกับ Data Connect ได้ที่ข้อมูลอ้างอิง CLI
คู่มืออ้างอิงนี้จะบันทึกข้อมูลต่อไปนี้
- Data Connect-specific entries in your
firebase.json
project configuration file. - การกำหนดค่า Data Connect ใน
dataconnect.yaml
และconnector.yaml
- บทบาท IAM ที่คุณจะต้องกำหนดค่าสำหรับโปรเจ็กต์ที่ใช้ Data Connect
ไฟล์การกำหนดค่าโปรเจ็กต์ Firebase
ข้อมูลอ้างอิงการกำหนดค่า firebase.json
ใช้ปุ่ม dataconnect
เพื่อกำหนดค่าบริการอย่างน้อย 1 รายการData Connect
ในโปรเจ็กต์
dataconnect: {
source: string // Path to the directory containing the dataconnect.yaml service file.
}
ข้อมูลอ้างอิงการกำหนดค่า dataconnect.yaml
ไฟล์ dataconnect.yaml
จะจัดเก็บข้อมูลการกำหนดค่าเกี่ยวกับตำแหน่งของแหล่งที่มาของสคีมาแอปพลิเคชัน แหล่งที่มาของตัวเชื่อมต่อ และข้อมูลการเชื่อมต่อแหล่งข้อมูล
นอกจากนี้ ไฟล์นี้ยังเป็นตัวระบุไดเรกทอรีโปรเจ็กต์สำหรับ
Firebase CLI ด้วย
ปุ่ม schemaValidation
จะควบคุมระดับการตรวจสอบความถูกต้องของสคีมาที่ดำเนินการ
เมื่อย้ายข้อมูลสคีมาระหว่างการติดตั้งใช้งาน หากไม่ได้ตั้งค่าไว้ ลักษณะการทำงานของคำสั่ง dataconect:sql:migrate
คือการใช้การเปลี่ยนแปลงที่เข้ากันได้และแจ้งให้คุณทราบก่อนที่จะดำเนินการเปลี่ยนแปลงที่เข้มงวด เมื่อตั้งค่าแล้ว ลักษณะการทำงานจะเป็นดังนี้
- โหมด
STRICT
สคีมาของฐานข้อมูลต้องตรงกับสคีมาของแอปพลิเคชันทุกประการก่อนจึงจะสามารถติดตั้งใช้งานสคีมาของแอปพลิเคชันได้ ระบบจะลบตารางหรือคอลัมน์ที่ไม่ได้ใช้ในData Connectสคีมา ออกจากฐานข้อมูล - โหมด
COMPATIBLE
สคีมาฐานข้อมูลต้องเข้ากันได้กับสคีมาแอปพลิเคชันก่อนจึงจะสามารถติดตั้งใช้งานสคีมาแอปพลิเคชันได้ การเปลี่ยนแปลงเพิ่มเติมถือเป็นตัวเลือก ความเข้ากันได้หมายความว่าการย้ายข้อมูลสคีมา จะอิงตามสคีมาของแอปพลิเคชันที่คุณเขียน ระบบจะไม่แก้ไของค์ประกอบใน ฐานข้อมูลที่สคีมาแอปพลิเคชันไม่ได้ใช้ ดังนั้นหลังจากที่ติดตั้งใช้งานแล้ว Backend อาจมีสคีมา ตาราง และคอลัมน์ที่ไม่ได้ใช้
ค่าสำหรับคีย์อื่นๆ ในไฟล์นี้จะอธิบายไว้ในความคิดเห็นด้านล่าง
# The top-level Firebase Data Connect YAML file.
# The Firebase Data Connect API version to target.
# Optional. Defaults to the latest version.
specVersion: string
# The ID of the Firebase Data Connect service resource.
# Required.
serviceId: string
# The location of the Firebase Data Connect service.
# Required.
location: string
# Required.
schema:
# Relative path to directory for schema definitions.
# Recursively loads all .gql files in this directory.
# Optional. If not present, defaults to ./schema.
source: string
# Datasource connection information.
# Required.
datasource:
# Required.
postgresql:
# The name of the PostgreSQL database.
# Required.
database: string
cloudSql:
# The ID of the CloudSQL instance resource.
# Required.
instanceId: string
# Schema validation mode for schema migrations.
# Defaults to unspecified/commented out, meaning you are prompted to
# review all changes during migration.
# If desired, uncomment and indicate one of "STRICT" or "COMPATIBLE".
schemaValidation: string
# Required.
# Relative paths to directories for connector definitions.
# Recursively loads all .gql files in the listed directories.
# All directories specified MUST contain a connector.yaml file.
connectorDirs: [string]
ไฟล์ YAML จะใช้โครงสร้างไดเรกทอรีเริ่มต้น (แต่กำหนดค่าได้) ดังนี้
./(project root)
/dataconnect
dataconnect.yaml
/schema
*.gql
/connector
connector.yaml
*.gql
การอ้างอิงการกำหนดค่า connector.yaml
ใช้ connector.yaml
เพื่อกำหนดค่าโหมดการตรวจสอบสิทธิ์เริ่มต้นและตัวเลือกการสร้าง SDK
# The connector-level YAML file.
# Required. The connector name of the Firebase Data Connect connector resource.
connectorId: string
# Optional. If not specified, no generated libraries (i.e. type-safe SDKs) will be generated.
generate:
# Optional.
javascriptSdk:
# Path to the directory that will be updated with the latest generated
# web SDK.
# Required.
- outputDir: string
# Path to your package.json directory. If specified, the new generated sdk will be installed in this path.
# Optional. If not provided, the package will not be auto-installed for you.
- packageJsonDir: string
# Name of the package to be created.
# Optional. Defaults to @firebasegen/<connectorID>
- package: string
<option>: string
# Optional.
swiftSdk:
# Path to the directory that will be updated with the latest generated
# iOS Swift SDK.
# Required.
- outputDir: string
# Name of the package to be created.
- package: string
<option>: string
# Optional.
kotlinSdk:
# Path to the directory that will be updated with the latest generated
# Android SDK.
# Required.
- outputDir: string
# Name of the package to be created.
- package: string
<option>: string
การกำหนดค่า IAM สำหรับโปรเจ็กต์ Data Connect
บทบาท IAM แบบละเอียดสำหรับ Data Connect
บทบาทพื้นฐานและบทบาทที่กำหนดไว้ล่วงหน้าของ Firebase จะแมปกับData Connectบทบาทระดับล่าง ดูการแมปได้ในตาราง
หากต้องการจัดการการมอบหมายบทบาท IAM แต่ละรายการสำหรับ Data Connect ในระดับที่ละเอียดขึ้น ให้ใช้Google Cloud คอนโซล
บทบาท IAM | สิทธิ์ |
---|---|
firebasedataconnect.googleapis.com/admin ผู้ดูแลระบบ Firebase Data Connect API บทบาทนี้รวมถึงผู้ดู Firebase Data Connect API เทียบเท่ากับ firebasedataconnect.* บทบาทเจ้าของระบบคลาวด์ ผู้แก้ไขระบบคลาวด์ ผู้ดูแลระบบ Firebase และผู้ดูแลระบบ Firebase Develop จะเป็นผู้ให้สิทธิ์นี้ |
สิทธิ์เข้าถึงทรัพยากร Firebase Data Connect API โดยสมบูรณ์ รวมถึงข้อมูลfirebasedataconnect.googleapis.com/operations.delete firebasedataconnect.googleapis.com/operations.cancel firebasedataconnect.googleapis.com/services.create firebasedataconnect.googleapis.com/services.update firebasedataconnect.googleapis.com/services.delete firebasedataconnect.googleapis.com/services.executeGraphql firebasedataconnect.googleapis.com/services.executeGraphqlRead firebasedataconnect.googleapis.com/schemas.create firebasedataconnect.googleapis.com/schemas.update firebasedataconnect.googleapis.com/schemas.delete firebasedataconnect.googleapis.com/schemaRevisions.create firebasedataconnect.googleapis.com/schemaRevisions.delete firebasedataconnect.googleapis.com/connectors.create firebasedataconnect.googleapis.com/connectors.update firebasedataconnect.googleapis.com/connectors.delete firebasedataconnect.googleapis.com/connectorRevisions.create firebasedataconnect.googleapis.com/connectorRevisions.delete
|
firebasedataconnect.googleapis.com/viewer ผู้ดู Firebase Data Connect API บทบาทนี้มีให้โดยเจ้าของระบบคลาวด์ ผู้แก้ไขระบบคลาวด์ ผู้ดูระบบคลาวด์ ผู้ดูแลระบบ Firebase ผู้ดู Firebase ผู้ดูแลระบบ Firebase Develop และผู้ดู Firebase Develop |
สิทธิ์การอ่านอย่างเดียวสำหรับทรัพยากร Firebase Data Connect API บทบาทไม่ได้
ให้สิทธิ์เข้าถึงข้อมูลcloudresourcemanager.googleapis.com/projects.list cloudresourcemanager.googleapis.com/projects.get firebasedataconnect.googleapis.com/operations.list firebasedataconnect.googleapis.com/operations.get firebasedataconnect.googleapis.com/locations.list firebasedataconnect.googleapis.com/locations.get firebasedataconnect.googleapis.com/services.list firebasedataconnect.googleapis.com/services.get firebasedataconnect.googleapis.com/schemas.list firebasedataconnect.googleapis.com/schemas.get firebasedataconnect.googleapis.com/schemaRevisions.list firebasedataconnect.googleapis.com/schemaRevisions.get firebasedataconnect.googleapis.com/connectors.list firebasedataconnect.googleapis.com/connectors.get firebasedataconnect.googleapis.com/connectorRevisions.list firebasedataconnect.googleapis.com/connectorRevisions.get
|
firebasedataconnect.googleapis.com/dataAdmin ผู้ดูแลข้อมูล API ของ Firebase Data Connect บทบาทนี้มีให้โดยเจ้าของระบบคลาวด์ ผู้แก้ไขระบบคลาวด์ ผู้ดูแลระบบ Firebase และผู้ดูแลระบบ Firebase Develop |
สิทธิ์การอ่านและการเขียนแหล่งข้อมูลโดยสมบูรณ์firebasedataconnect.googleapis.com/services.executeGraphql firebasedataconnect.googleapis.com/services.executeGraphqlRead
|
firebasedataconnect.googleapis.com/dataViewer ผู้ดูข้อมูล Firebase Data Connect API บทบาทนี้มีให้โดยเจ้าของระบบคลาวด์ ผู้แก้ไขระบบคลาวด์ ผู้ดูแลระบบ Firebase และผู้ดูแลระบบ Firebase Develop |
สิทธิ์การอ่านอย่างเดียวสำหรับแหล่งข้อมูลfirebasedataconnect.googleapis.com/services.executeGraphqlRead
|