简体   繁体   English

具有集合的 firestore 查询文档包含一个文档

[英]firestore query document that have a collection contains a document

in collection A, want to find all documents that has a collection named B that have a document id 1234. Any quick way?在集合 A 中,想要查找包含名为 B 的集合且文档 ID 为 1234 的所有文档。有什么快速的方法吗?

I only know that there is a quick way to find documents that have a specific item in an array which is a property.我只知道有一种快速的方法可以找到在作为属性的数组中具有特定项目的文档。 https://firebase.google.com/docs/firestore/query-data/queries#array_membership https://firebase.google.com/docs/firestore/query-data/queries#array_membership

Firestore queries can only order/filter on fields in the documents that they return. Firestore 查询只能对它们返回的文档中的字段进行排序/过滤。 There is no way to filter on fields in other documents, or the existence of other documents.无法过滤其他文档中的字段,或其他文档的存在。

The common way to deal with this is to have a field in the parent document that indicates whether the child document you're looking for exists, and updated that on every relevant write.处理此问题的常用方法是在父文档中有一个字段,指示您要查找的子文档是否存在,并在每次相关写入时更新该字段。 Then you can use that field to filter the documents in collection A.然后您可以使用该字段来过滤集合 A 中的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM