在Firestore中对多个集合进行查询 [英] Making a query to multiple collection in firestore
问题描述
我有两个集合,其中一个集合引用了另一个.下面是我的结构:
I have two collections where one collection is referencing another. Below is my structure:
CURRENCY_PAIR
- CurrencyPair_Name
- CurrencyPair_id
CURRENCY_PAIR_LIMIT
- Limit_Currency_Pair_Id: CURRENCY_PAIR/0chTWgOpzolSxj590N1U < =引用CURRENCY_PAIR集合中的文档
- 限价购买价格阈值
- Limit_Currency_Pair_Id : CURRENCY_PAIR/0chTWgOpzolSxj590N1U <=makes a reference to the document in the CURRENCY_PAIR collection
- Limit_Buy_Price_Threshhold
如何查询两个集合,以便当我获得货币对时,它等于添加到数据库的 Limit_Buy_Price_Threshhold
字段.
How can i query both collections such that when i get a currency pair, it is equal to the Limit_Buy_Price_Threshhold
field that was added to the db with.
推荐答案
如该线程所提供,Firestore不会提到服务器端JOIN的概念非常接近您提到要查询两个集合时要实现的目标.
As provided on this thread, Firestore does not have a concept of server-side JOIN which is very near to what you want to achieve when you mentioned that you wanted to query both collections.
What I could think of is that you could remodel your database in a way that you can perform collection group queries. It works by putting CURRENCY_PAIR_LIMIT
as a subcollection to the document in CURRENCY_PAIR
.
这篇关于在Firestore中对多个集合进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!