适用于 Firestore 的连接器(写入)

使用 Workflows 连接器将数据写入 Firestore。

代码示例

YAML

# This workflow demonstrates how to use the Firestore connector:
# Write data to a document in the default Firestore database
# Expected output: "projects/PROJECT_ID/databases/(default)/documents/peopleDatabase/smith.j"
- init_variables:
    assign:
      - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - collection: "peopleDatabase"
      - document: "smith.j"
      - values_to_write:
          FirstName:
            stringValue: "John"
          LastName:
            stringValue: "Smith"
          Age:
            integerValue: 32
- write_to_firestore:
    call: googleapis.firestore.v1.projects.databases.documents.patch
    args:
      name: ${"projects/"+project+"/databases/(default)/documents/"+collection+"/"+document}
      body:
        fields: ${values_to_write}
    result: write_result
- last:
    return: ${write_result.name}

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器