【问题标题】:Firestore query a filed against multiple valuesFirestore 针对多个值查询一个文件
【发布时间】:2019-10-19 11:35:51
【问题描述】:

是否可以针对一组值查询文档字段,在该数组中它将返回包含数组元素值之一的字段

                 _fireStore
                .collection('articles')
                .orderBy('created')
                .where('projectName', isEqualTo: listHearted)
                .getDocuments()
                .asStream(),

【问题讨论】:

  • 不清楚你在问什么。请编辑问题以显示您可能希望从查询中收到哪些文档的示例。

标签: flutter google-cloud-firestore


【解决方案1】:

【讨论】:

    【解决方案2】:

    我已经使用流中的流完成了它。

     Stream<List<DocumentSnapshot>> streamDoc;
      StreamController<List<DocumentSnapshot>> controller =
      StreamController<List<DocumentSnapshot>>();
    
     void docRef() {
    Firestore _fireStore = Firestore.instance;
    
    Stream<QuerySnapshot> snapshot = _fireStore
        .collection('articles')
        .orderBy('created')
        .getDocuments()
        .asStream();
    
    List<DocumentSnapshot> listDoc = List<DocumentSnapshot>();
    snapshot.listen((snapshot) {
      snapshot.documents.forEach((e) {
        if (SharedPrefList.listHearted
                .contains(e.data['projectName'].toString()) &&
            widget.type == 'hearted') {
          listDoc.add(e);
          controller.add(listDoc);
        }
        if (SharedPrefList.listSeen
                .contains(e.data['projectName'].toString()) &&
            widget.type == 'seen') {
          listDoc.add(e);
          controller.add(listDoc);
        }
      });
    });
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-18
      • 2023-03-09
      • 2019-04-05
      • 2013-04-28
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多