Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.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
Google cloud firestore 检查Firestore集合中是否存在多个文档id_Google Cloud Firestore - Fatal编程技术网

Google cloud firestore 检查Firestore集合中是否存在多个文档id

Google cloud firestore 检查Firestore集合中是否存在多个文档id,google-cloud-firestore,Google Cloud Firestore,我想在10个文档ID的列表中检查集合中存在多少文档ID。一种方法是将文档ID存储在文档中,并在操作符中使用 const result = await this.afs.collection(path).where('id', 'in', ['doc1', 'doc2']).get(); 是否有一种方法可以避免将文档id存储在文档中。对于此特定查询,您可以使用。它返回可在查询的字段路径中使用的标记: this.afs.collection(path).where(FieldPath.docume

我想在10个文档ID的列表中检查集合中存在多少文档ID。一种方法是将文档ID存储在文档中,并在操作符中使用

const result = await this.afs.collection(path).where('id', 'in', ['doc1', 'doc2']).get();

是否有一种方法可以避免将文档id存储在文档中。

对于此特定查询,您可以使用。它返回可在查询的字段路径中使用的标记:

this.afs.collection(path).where(FieldPath.documentId(), 'in', ['doc1', 'doc2'])

我已经将您链接到纯JavaScript文档。如果您使用的是Angular,它可能会有一种稍微不同的方式来获取该标记值,但它将位于名为
FieldPath

的类中,工作非常完美。太多了!!