See Henry's answer, as we've no made Array Contains queries available.

Unfortunately not yet, although it's on our roadmap.

In the meantime, you'll need to use a map instead, in the form of:

photos: {
    id1: true
    id2: true
}

Now you can find all users with id1 by filtering by photos.id1 == true.

Read more about querying such sets in the Firebase documentation.


Added 'array-contains' query operator for use with .where() to find documents where an array field contains a specific element.

https://firebase.google.com/support/release-notes/js 5.3.0

Update: also available in @google-cloud/firestore: https://github.com/googleapis/nodejs-firestore/releases/tag/v0.16.0

Update 2 https://firebase.googleblog.com/2018/08/better-arrays-in-cloud-firestore.html

Update 3 now available in Admin Node.js SDK v6.0.0 https://github.com/firebase/firebase-admin-node/releases