Google Firestore - What is OR equivalent?

2019-06-10 07:13发布

问题:

I see having mulitple where acts like AND, but how about OR?

回答1:

You can't really do an OR query in Cloud Firestore.

As a workaround, you could run two separate queries and merge them together on the client, or add some custom field that would essentially perform the "OR" query for you on the database. (For an example of that latter one, if you know you're going to often run an "age > 65 OR age < 18" query on the database, you could create a specific age_high_or_low field that you would set to true if the age field were greater than 65 or less then 18.)