Firebase CLI ช่วยให้คุณจัดการโปรเจ็กต์ Firebase ในไดเรกทอรีโปรเจ็กต์ในเครื่องที่ควบคุมเวอร์ชันได้ ซึ่งรวมถึงData Connect บริการในโปรเจ็กต์ของคุณ ตัวเชื่อมต่อสำหรับบริการเหล่านั้น และทรัพยากรต่างๆ เช่น สคีมา แหล่งที่มาของคําค้นหาและการเปลี่ยนแปลงสําหรับตัวเชื่อมต่อแต่ละรายการ นอกจากนี้ CLI ยังช่วยให้คุณ ติดตั้งและใช้งานโปรแกรมจำลอง Firebase Data Connect ได้ด้วย CLI เป็นทางเลือกที่มีประสิทธิภาพแทนการทำงานในFirebaseคอนโซล
ดูวิธีการติดตั้งFirebaseการทดลอง CLI สำหรับ โปรแกรมตัวอย่างแบบส่วนตัวและคำสั่ง CLI ที่เกี่ยวข้องกับ Data Connect ได้ที่ข้อมูลอ้างอิง CLI
คู่มืออ้างอิงนี้จะบันทึกข้อมูลต่อไปนี้
- Data Connect-specific entries in your 
firebase.jsonproject 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.deletefirebasedataconnect.googleapis.com/operations.cancelfirebasedataconnect.googleapis.com/services.createfirebasedataconnect.googleapis.com/services.updatefirebasedataconnect.googleapis.com/services.deletefirebasedataconnect.googleapis.com/services.executeGraphqlfirebasedataconnect.googleapis.com/services.executeGraphqlReadfirebasedataconnect.googleapis.com/schemas.createfirebasedataconnect.googleapis.com/schemas.updatefirebasedataconnect.googleapis.com/schemas.deletefirebasedataconnect.googleapis.com/schemaRevisions.createfirebasedataconnect.googleapis.com/schemaRevisions.deletefirebasedataconnect.googleapis.com/connectors.createfirebasedataconnect.googleapis.com/connectors.updatefirebasedataconnect.googleapis.com/connectors.deletefirebasedataconnect.googleapis.com/connectorRevisions.createfirebasedataconnect.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.listcloudresourcemanager.googleapis.com/projects.getfirebasedataconnect.googleapis.com/operations.listfirebasedataconnect.googleapis.com/operations.getfirebasedataconnect.googleapis.com/locations.listfirebasedataconnect.googleapis.com/locations.getfirebasedataconnect.googleapis.com/services.listfirebasedataconnect.googleapis.com/services.getfirebasedataconnect.googleapis.com/schemas.listfirebasedataconnect.googleapis.com/schemas.getfirebasedataconnect.googleapis.com/schemaRevisions.listfirebasedataconnect.googleapis.com/schemaRevisions.getfirebasedataconnect.googleapis.com/connectors.listfirebasedataconnect.googleapis.com/connectors.getfirebasedataconnect.googleapis.com/connectorRevisions.listfirebasedataconnect.googleapis.com/connectorRevisions.get
       | 
    
        firebasedataconnect.googleapis.com/dataAdminผู้ดูแลข้อมูล Firebase Data Connect API บทบาทนี้มีให้โดยเจ้าของระบบคลาวด์ ผู้แก้ไขระบบคลาวด์ ผู้ดูแลระบบ Firebase และผู้ดูแลระบบ Firebase Develop  | 
      
        สิทธิ์การอ่านและการเขียนแหล่งข้อมูลโดยสมบูรณ์firebasedataconnect.googleapis.com/services.executeGraphqlfirebasedataconnect.googleapis.com/services.executeGraphqlRead
       | 
    
        firebasedataconnect.googleapis.com/dataViewerโปรแกรมดูข้อมูล Firebase Data Connect API บทบาทนี้มีให้โดยเจ้าของระบบคลาวด์ ผู้แก้ไขระบบคลาวด์ ผู้ดูแลระบบ Firebase และผู้ดูแลระบบ Firebase Develop  | 
      
        สิทธิ์การอ่านอย่างเดียวสำหรับแหล่งข้อมูลfirebasedataconnect.googleapis.com/services.executeGraphqlRead
       |