如何在不知道集合名称/文档名称的情况下在Firestore中找到特定但深埋的文档? [英] How can I find a specific but deep buried document in Firestore without knowing the collection/documet name?

查看:41
本文介绍了如何在不知道集合名称/文档名称的情况下在Firestore中找到特定但深埋的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firestore遇到了一些麻烦,希望您能提供帮助.

I am having some trouble with Firestore and hope you can help out.

所以我已经按照如下方式设置了我的Firestore:

So I have setup my Firestore like following:

我有一个用户"收集具有称为"User1"的一堆文件的集合.和"User2"等

I have a "Users" collection with a bunch of documents called "User1" and "User2" etc.

在每个文档中都有一个称为房屋"的另一个收藏夹

and inside each of these documents there is another collection called "Houses"

在其中有一堆名为"House1"的文档,和"House2"等

and inside this there is a bunch of documents called "House1" and "House2" etc.

这些都包含相同的fieldName,但具有唯一的fieldValues.

and these all contain the same fieldNames but with unique fieldValues.

所以我的问题是,假设我知道这些众议院文件之一的fieldValue为"WaterHouse",在其中,但我不知道在哪个用户文档和内部文档中.然后,我如何解析所有用户文档和房屋文档,并获得包含fieldValue"WaterHouse"的文档?

So my question is, suppose I know that one of these House documents has the fieldValue "WaterHouse" in it but I dont know in which User document and House Document. How can i then parse through all the User Documents and the House documents and get the document that contains the fieldValue "WaterHouse"?

推荐答案

您将需要知道要搜索的集合的名称.如果您不知道集合名称,则无法找到文档.

You will need to know the name of the collection(s) to search. If you don't know the collection name, there is no way to find documents.

但是您不需要知道集合的完整路径.因此,如果您知道房屋中存在什么文档,但是不知道该文档位于哪个 Users 文档中,则可以使用

But you don't need to know the entire path to the collection. So if you know what document exists in Houses, but you don't know what Users document it is under, you can use a Collection Group Query to search across all collections named Houses.

这篇关于如何在不知道集合名称/文档名称的情况下在Firestore中找到特定但深埋的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆