颤动多个Firestore查询 [英] Flutter Multiple Firestore Queries

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

问题描述

我正在尝试对Firestore进行多个查询,并将结果合并到一个流中,例如这里。我尝试使用 StreamGroup.merge(),但它只返回一个流的结果。我注意到它实际上确实获取了所有流的数据,但是仅在所有内容完成后才返回一个。这是我所做的:

I am trying to make multiple queries to Firestore and merge the results into one stream like here. I tried using StreamGroup.merge() but it's only returning the results of one stream. I noticed that it does actually get data for all the streams but only returns one when everything completes. Here is what I did:

Stream getStream(){
    List<Stream> streams = [];     

    streams.add(Firestore.instance.collection(Constants.REQUESTS_NODE).
    where("municipality",isEqualTo: "City of Johannesburg Metropolitan").
    where("service_id",isEqualTo: 2).
    snapshots());
    streams.add(Firestore.instance.collection(Constants.REQUESTS_NODE).
    where("municipality",isEqualTo: "Lesedi Local").where("service_id",isEqualTo: 2).
    snapshots());    

    return StreamGroup.merge(streams);

  }

我在想什么,做错了什么?我这样做的原因是为了补偿Firestore缺少 OR 运算符。

What am I missing and doing wrong? The reason I'm doing this is to compensate for Firestore's lack of OR operator.

推荐答案

对于将来可能需要帮助的任何人,我设法使用 StreamZip 解决了该问题。您可以从网站

For anyone in future who might need assistance with this, I managed to solve it using StreamZip. You can read more about it from this website

这篇关于颤动多个Firestore查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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