简体   繁体   English

Angular Firestore Group collection 获取多个文档下的所有文档

[英]Angular Firestore Group collection get all docs under a multiple document

structure of my Firestore database:我的 Firestore 数据库的结构:

数据库结构

Restaurant --> Data --> Menu -->All dishes餐厅 --> 数据 --> 菜单 --> 所有菜品

I want to get all dishes under all restaurants and show them on a single page just like all under breakfast names of all restaurants having breakfast and under them, all breakfast just like in the image below.我想获取所有餐厅下的所有菜肴,并在一个页面上显示它们,就像所有吃早餐的餐厅的早餐名称下的所有菜一样,在它们下面,所有早餐如下图所示。

界面截图

Anyone please suggest to me some ideas to achieve this?任何人请向我建议一些想法来实现这一目标?

Does the Firestore Group collection gets all docs under multiple documents? Firestore Group 集合是否获取多个文档下的所有文档?

A collection group query , will always return documents from all collections with the exact same name, no matter if it's a top-level collection or a sub-collection. 集合组查询将始终返回所有collections 中具有完全相同名称的文档,无论它是顶级集合还是子集合。

So in your example, you can get all dishes by using a collection group query on the menu sub-collection.因此,在您的示例中,您可以通过对菜单子集合使用集合组查询来获取所有菜肴。

If you want to order the documents (dishes) to the restaurant, I would recommend not using a group query but rather to query the restaurants and than for each restaurant query the dishes in a single query.如果您想向餐厅订购文件(菜肴),我建议不要使用组查询,而是查询餐厅,而不是在单个查询中为每个餐厅查询菜肴。

Collection Group queries would have some issues in your case, mainly that you could not easily query more documents (dishes) of the same restaurant in one query when the user swipes to the left.集合组查询在您的情况下会有一些问题,主要是当用户向左滑动时,您无法在一次查询中轻松查询同一家餐厅的更多文档(菜肴)。 They are great if you would want a page where there are all dishes without the restaurant association, but if you want a structure like your UI screenshot suggest, I would go with separate queries.如果你想要一个没有餐厅协会的所有菜肴的页面,它们就很棒,但如果你想要一个像你的 UI 屏幕截图建议的结构,我会 go 有单独的查询。

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

相关问题 如何在 Firestore 集合组查询 Flutter 中获取子集合文档 - How to Get Subcollection docs in Firestore Collection Group Query Flutter 从 2 collection firestore 获取所有文档 - get all document from 2 collection firestore 如何使用angular firestore获取集合中的文档列表 - how to get list of document in a collection, using angular firestore Firestore Angular 文档中的集合 - Firestore Angular Collection inside Document 无法从集合 firebase firestore 中获取所有文档 - Can't get all document from collection firebase firestore 如何从 firestore 一次获取多个集合组的文档? - How to get multiple collection group's documents at once from firestore? 如何从Flutter上的Firestore获取collections的列表和一个集合下所有字段的列表? - How to get a list of collections and a list of all fields under a collection from Firestore on Flutter? _Future 的实例<int>当我试图在 Firestore 中获取我的“收藏”的全部“文档”时,我得到的就是这些</int> - Instance of _Future<int> is all I get when I try to get the total 'document' of my 'collection' in Firestore Angular Firestore - 我想获取集合的文档 ID 并将它们转换为数组 - Angular Firestore - I want get document ID's of collection and convert them to an array Firestore - 如何在将文档添加到集合后获取文档 ID - Firestore - How to get document id after adding a document to a collection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM