如何使用Firestore Rest API使用阵列?

问题描述 投票:0回答:1

即使遵循Firestore文档,我也找不到达到请求的方法。 我尝试了此请求:

Path(补丁方法):

Https://firestore.googleapis.com/v1/projects/social-autt/databases/(默认)

body: { "updateTransforms": [ { "fieldPath": "kaja", "appendMissingElements": { "values": [ { "stringValue": "Aasd" } ] } } ] }

response:

{ "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name \"updateTransforms\" at 'document': Cannot find field.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "document", "description": "Invalid JSON payload received. Unknown name \"updateTransforms\" at 'document': Cannot find field." } ] } ] } }
    

在答案上,我如何在Firestore文档上添加/删除数组元素,并通过REST?
以及
firebase rest google-cloud-firestore
1个回答
0
投票

Write

DocumentTransform
FieldTransform的文档添加/删除数组元素。
,我能够在Postman中执行此阵列联盟:
请求的JSON:

{ "writes": [{ "transform": { "document": "projects/projectID.../databases/(default)/documents/79447051/test", "fieldTransforms": [ { "fieldPath": "array", "appendMissingElements": { "values": [ { "stringValue": "third" } ] } } ] } }] } enter image description here在此:

BluredBit是我的项目ID

是收集ID(以及您的问题ID)

79447051
    是我的文档ID
  • test
    是我们正在更新的数组字段的名称
  • array
    是我们要添加到数组中的值(如果尚未在那里)
  • 我从Firestore回来的回应:
    third
  • 
    
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.