3

I have a collection users in firestore where one of the fields is "contact_person".

Then I have an array arrNames {'Jim', 'Danny', 'Rachel'} in my frontend and I want to get all users that have either of these names in their "contact_person" field. Something like where("contact_person" IN arrNames)

How could I do that?

Jaime
  • 736
  • 1
  • 8
  • 27

2 Answers2

4

This is currently not possible within the Firestore API. You will need to do a separate get for each document, unless the names happen to be in a single contiguous range.

Also see:

Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
1

It is now possible (from 11/2019) https://firebase.googleblog.com/2019/11/cloud-firestore-now-supports-in-queries.html but keep in mind that the array size can't be greater than 10.

db.collection("projects").where("status", "in", ["public", "unlisted", "secret"]);

Simon
  • 5,502
  • 5
  • 38
  • 86