如何在不知道集合名称/文档名称的情况下在Firestore中找到特定但深埋的文档?

编程入门 行业动态 更新时间:2024-10-26 06:31:10
本文介绍了如何在不知道集合名称/文档名称的情况下在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 文档中,则可以使用收藏组查询,以搜索所有名为 Houses 的收藏集

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中找到特定但深埋的文档?

本文发布于:2023-10-23 22:30:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   文档   深埋   情况下   中找到

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!