[英]Flutter : How to get Stream Query with OR condition in [Firebase]
I want to implement OR condition in flutter using the multiple where();
我想使用多个
where();
在颤振中实现 OR 条件where();
method but this returns AND
condition.方法,但这会返回
AND
条件。
Following is my code for query以下是我的查询代码
Future<Stream<QuerySnapshot>> getOrders() async {
return FirebaseFirestore.instance
.collection("Orders")
.orderBy("timestamp")
.where("isCredentialUploaded", isEqualTo: true),
.where("isTransactionDone", isEqualTo: true)
.snapshots();
}
But this makes the AND Condition, like this但这使得 AND 条件,像这样
if(isCredentialUploaded && isTransactionDone)
Is there any way I can get the OR condition in Firebase Firestore?有什么办法可以在 Firebase Firestore 中获得 OR 条件?
Result i want:我想要的结果:
if(isCredentialUploaded || isTransactionDone)
so, in the official documentation of Firebase & Flutter we notice that after using the query we must use get()
instead of snapshot()
.所以,在Firebase & Flutter的官方文档中,我们注意到在使用查询之后我们必须使用
get()
而不是snapshot()
。
try this code :试试这个代码:
Future<Stream<QuerySnapshot>> getOrders() async {
return FirebaseFirestore.instance
.collection("Orders")
.orderBy("timestamp")
.where("isCredentialUploaded", isEqualTo: true),
.where("isTransactionDone", isEqualTo: true)
.get();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.