在Firestore中对多个集合进行查询 [英] Making a query to multiple collection in firestore

查看:53
本文介绍了在Firestore中对多个集合进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个集合,其中一个集合引用了另一个.下面是我的结构:

I have two collections where one collection is referencing another. Below is my structure:

CURRENCY_PAIR

  1. CurrencyPair_Name
  2. CurrencyPair_id

CURRENCY_PAIR_LIMIT

  1. Limit_Currency_Pair_Id: CURRENCY_PAIR/0chTWgOpzolSxj590N1U < =引用CURRENCY_PAIR集合中的文档
  2. 限价购买价格阈值
  1. Limit_Currency_Pair_Id : CURRENCY_PAIR/0chTWgOpzolSxj590N1U <=makes a reference to the document in the CURRENCY_PAIR collection
  2. 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屋!

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