0

in collection A, want to find all documents that has a collection named B that have a document id 1234. Any quick way?

I only know that there is a quick way to find documents that have a specific item in an array which is a property. https://firebase.google.com/docs/firestore/query-data/queries#array_membership

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Aron
  • 169
  • 8
  • The Firebase Realtime Database and Cloud Firestore are two separate databases. Please only mark your question with the relevant tag, not with both. – Frank van Puffelen Feb 22 '22 at 02:14

1 Answers1

1

Firestore queries can only order/filter on fields in the documents that they return. There is no way to filter on fields in other documents, or the existence of other documents.

The common way to deal with this is to have a field in the parent document that indicates whether the child document you're looking for exists, and updated that on every relevant write. Then you can use that field to filter the documents in collection A.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807