Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用WriteBatch删除列表中的文档引用?_Java_Firebase_Google Cloud Firestore - Fatal编程技术网

Java 如何使用WriteBatch删除列表中的文档引用?

Java 如何使用WriteBatch删除列表中的文档引用?,java,firebase,google-cloud-firestore,Java,Firebase,Google Cloud Firestore,我正在使用Firebase云数据库。这个问题类似于,但现在我感兴趣的是DocumentReferences。我查询了一个集合,得到了一个文档列表。每个文档都包含一个字段cars,其中包含DocumentReferences。每个DocumentReference引用一个表示汽车的文档。鉴于carsPath是car文档的路径,我想删除该列表中的DocumentReferences。我正在使用writeback。如果cars仅包含路径,则使用以下方法将很容易: batch.update(snapsh

我正在使用Firebase云数据库。这个问题类似于,但现在我感兴趣的是
DocumentReferences
。我查询了一个集合,得到了一个文档列表。每个文档都包含一个字段
cars
,其中包含
DocumentReferences
。每个
DocumentReference
引用一个表示汽车的文档。鉴于
carsPath
是car文档的路径,我想删除该列表中的
DocumentReferences
。我正在使用
writeback
。如果
cars
仅包含路径,则使用以下方法将很容易:

batch.update(snapshot.getReference(), "cars", FieldValue.arrayRemove(carPath));

如果我们使用
DocumentReferences
而不是
Strings
,有没有类似的方法?

只需将DocumentReference对象而不是字符串传递给
FieldValue.arrayRemove()
。引用的路径必须与数组中的路径完全匹配。

这里的DocumentReference是什么意思?如何使用
停车场
?是否为
FieldValue.arrayRemove(fireDB.document(carPath))
?执行构建DocumentReference类型对象所需的任何操作@道格:这是个好建议。我鼓励您将此评论作为答案发布。