适用于 Firestore 的连接器(读取)

使用 Workflows 连接器从 Firestore 读取数据。

代码示例

YAML

- initialize:
    assign:
      - project: "myproject123"
      - collection: "myEntries"
      - document: "Report"
- read_item:
    try:
      call: http.get
      args:
        url: ${"https://firestore.googleapis.com/v1/projects/"+project+"/databases/(default)/documents/"+collection+"/"+document}
        auth:
          type: OAuth2
      result: document_value
    except:
      as: e
      steps:
        - is_the_key_found:
            switch:
              - condition: ${e.code == 404}
                next: document_not_found
              - condition: ${e.code == 403}
                next: auth_error
    next: document_found
- document_not_found:
    return: "Document not found."
- auth_error:
    return: "Authentication error."
- document_found:
    return: ${document_value.body.fields.LastName.stringValue}

后续步骤

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