如何使用 AngularFireBase 库在 Firestore 数据库中进行内部连接?

How to make an inner join in the Firestore database with the AngularFireBase library?

我目前有 2 个集合,一个名为 "cart",包含一个产品 ID 列表,第二个名为 "products",我想要实现的是获得一个列表,其中包含用户已添加到您的购物车的所有数据和产品

我花了几天时间寻找制作 "internal union" 的方法,但我没有取得太大的成功,我找到的信息已经超过 1 年了,我留下了一些信息的链接我阅读

https://angularfirebase.com/lessons/firestore-joins-similar-to-sql/ https://angularfirebase.com/snippets/combine-firestore-collections-into-a-single-array-observable/

现在我有购物车列表,其中包含用户同意的产品。

cart
  KeyFirestore1
    [0]
      id_product:product1
    [1]
      id_product:product2

以及产品列表

products
  product1
    name:"apple"
    price:20.00
    id_product:"product1"
  product2
    nombre:"ice cream"
    price:40.00
    id_product:"product2"

而且我想在咨询时只得到一个列表

cart_products
  KeyFirestore1
    [0]
      name:"apple"
      price:20.00
      id_product:"product1"
    [1]
      name:"ice cream"
      price:40.00
      id_product:"product2"

为此,您应该使用 forkJoin。 解释了如何实施它。

如回答中所述,"If you need to react on updates from any of the streams — try combineLatest."

这里有更多关于combineLatest operator and a full example的细节(请阅读第二个场景)。