【问题标题】:How to perform a query in Firestore string field to match against multiple values?如何在 Firestore 字符串字段中执行查询以匹配多个值?
【发布时间】:2021-09-22 12:09:47
【问题描述】:

我在 Firestore 中有一个集合,其中有一个字段 status,它是“COMPLETE”、“INCOMPLETE”或“ON HOLD”

如何执行只返回匹配“COMPLETE”“INCOMPLETE”的文档的查询?

  FirebaseFirestore.instance.collection('tasks')
    .where('status', isEqualTo: 'COMPLETE')
    .where('status', isEqualTo: 'INCOMPLETE');

【问题讨论】:

    标签: firebase flutter google-cloud-firestore


    【解决方案1】:

    您正在寻找whereIn 运算符,它将获取提供的字段(在本例中为status)具有传递的数组/列表中提供的任一值的文档:

    FirebaseFirestore.instance.collection('tasks').where('status', whereIn: ['COMPLETE','INCOMPLETE']);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-17
      • 1970-01-01
      • 2020-08-21
      相关资源
      最近更新 更多