Reputation: 127
i have a collection "Orders", having a srtucture like this
dishname :
"Biryani"
dishprice:
"350"
dishquantity:
"1"
hotelemail:
"[email protected]"
hotelname :
"Apk"
time
April 13, 2020 at 2:51:11 PM UTC+5
useremail
"[email protected]"
username
"pasha"
usernum
"03416889912"
orderstatus
"Pending"
now i want's to perform a query on this collection which resembles like this get ALL the orders where (orderstatus == "Pending" OR (orderstatus == "collected" AND useremail = "someemail") OR (orderstatus == "distapched" AND useremail = "someemail")
Upvotes: 0
Views: 147
Reputation: 317372
What you're trying to do is not possible in a single query, since Firestore doesn't support logical OR in the way that you're specifying here. Instead of a logical OR, you will have to instead perform separate queries for each OR condition, and merge the results in the client. So, in your specific case, you will need three queries for:
orderstatus == "Pending"
(orderstatus == "collected" AND useremail = "someemail")
(orderstatus == "distapched" AND useremail = "someemail")
Then your code can take the results and filter out duplicate documents if needed.
Upvotes: 1