1

I'm trying to get all the documents that have my phone number as the fromNumber or the toNumber. My call right now is:

database.collection('documents').where('fromNumber','==',myPhoneNumber).get().then();

Instead of making 2 calls, one to check the fromNumber and the second one to check the toNumber, how can I check both at the same time and in the same .get()?

Btw: tested this code:

database.collection('documents')
    .where('fromNumber','==',myPhoneNumber)
    .where('toNumber','==',myPhoneNumber).get()
   .then();

But it checks if both are true, it's an AND instead of the OR I'm looking for.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
petithomme
  • 509
  • 1
  • 8
  • 29

1 Answers1

0

According to the official documentation, there a are some query limitations, when it comes to Firestore:

Cloud Firestore does not support the following types of queries:

Logical OR queries. In this case, you should create a separate query for each OR condition and merge the query results in your app.

As suggested in the documentation, you should create two separate queries and merge the result cliend side.

Community
  • 1
  • 1
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • 1
    Ah I was hoping that wasn't the case. Couldn't find it in the documentation so thank you for the link. I'll mark this answer as the correct one and let's hope they add that feature in the future. – petithomme Nov 03 '18 at 21:41