【问题标题】:Cloud Firestore CollectionReference query fieldCloud Firestore CollectionReference 查询字段
【发布时间】:2019-08-23 06:26:34
【问题描述】:

我正在使用 Flutter 和 Firebase Cloud Firestore。请问,如何按字段查询 CollectionReference?喜欢:

* database
** collection
*** document
**** field (string) to query

【问题讨论】:

标签: firebase dart flutter google-cloud-firestore


【解决方案1】:

您必须使用where 方法查询您的收藏。然后,您将获得所有符合条件的文档。

firestore.collection('myCollection').where('yourField', isEqualTo: 'any');

【讨论】:

  • 嗨,朋友!感谢您的回答!作为我的问题的补充,我想用我想搜索的文本查询string started
【解决方案2】:

我正在使用它,它可以工作

CollectionReference getRecord() {
    try {
      CollectionReference collectionReference = Firestore.instance.collection("collection-one").document("document one").collection("collection-two").where('field name', isEqualTo: 'string value');
      return collectionReference;
    } catch (e) {
      print('throw:' + e);
      return null;
    }
  }

【讨论】:

    猜你喜欢
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 2018-10-15
    • 2020-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-14
    相关资源
    最近更新 更多