Firebase 颤振/飞镖询问Napshot isEqualTo或操作员?

Firebase 颤振/飞镖询问Napshot isEqualTo或操作员?,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,我想问一下,集合中是否有现场测试等于1 2或4的文档。但不幸的是,我没有找到合适的解决办法 不幸的是,这是我的方法,它在这里不起作用,等于1 | 2 | 4。是不是没有电话或接线员| Future getPostsToday() async { ... var firestore = Firestore.instance; QuerySnapshot qn = await firestore.collection("Data").where("test", isEq

我想问一下,集合中是否有现场测试等于1 2或4的文档。但不幸的是,我没有找到合适的解决办法

不幸的是,这是我的方法,它在这里不起作用,等于1 | 2 | 4。是不是没有电话或接线员|

Future getPostsToday() async { 
   ...
    var firestore =  Firestore.instance;
    QuerySnapshot qn = await firestore.collection("Data").where("test",   isEqualTo: 1 | 2 | 4 ).getDocuments();
    return qn.documents;  
 }
Cloud Firestore不支持以下类型的查询:

逻辑或查询。在这种情况下,您应该为每个OR条件创建一个单独的查询,并将查询结果合并到 应用程序。 资料来源:

编辑:

所以我想你可以这样做:

Future<List<DocumentSnapshot>> getPostsToday() async {
  final collection = Firestore.instance.collection("Data");

  // separate query for each OR condition
  final querySnapshots = await Future.wait([
    collection.where("test", isEqualTo: 1).getDocuments(),
    collection.where("test", isEqualTo: 2).getDocuments(),
    collection.where("test", isEqualTo: 4).getDocuments(),
  ]);

  // merge the query results and return
  return <DocumentSnapshot>[
    ...querySnapshots[0].documents,
    ...querySnapshots[1].documents,
    ...querySnapshots[2].documents,
  ];
}
Cloud Firestore不支持以下类型的查询:

逻辑或查询。在这种情况下,您应该为每个OR条件创建一个单独的查询,并将查询结果合并到 应用程序。 资料来源:

编辑:

所以我想你可以这样做:

Future<List<DocumentSnapshot>> getPostsToday() async {
  final collection = Firestore.instance.collection("Data");

  // separate query for each OR condition
  final querySnapshots = await Future.wait([
    collection.where("test", isEqualTo: 1).getDocuments(),
    collection.where("test", isEqualTo: 2).getDocuments(),
    collection.where("test", isEqualTo: 4).getDocuments(),
  ]);

  // merge the query results and return
  return <DocumentSnapshot>[
    ...querySnapshots[0].documents,
    ...querySnapshots[1].documents,
    ...querySnapshots[2].documents,
  ];
}

谢谢,但如果没有or运算符,我如何实现这一点?获取错误无法推断类型参数“E”。试图推断“E”的“dynamic”不起作用:在需要“List”的地方使用声明为“List”的返回类型。类型“dynamic”是从以下内容推断的:参数“element”声明为“E”,但参数为“dynamic”。考虑将显式类型参数传递给泛型。有什么建议可以解决吗。谢谢。谢谢。但如果没有or运算符,我如何实现这一点?获取错误无法推断类型参数“E”。试图推断“E”的“dynamic”不起作用:在需要“List”的地方使用声明为“List”的返回类型。类型“dynamic”是从以下内容推断的:参数“element”声明为“E”,但参数为“dynamic”。考虑将显式类型参数传递给泛型。有什么建议可以解决吗。谢谢