[英]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.