I am trying to retrieve data from one collection depending on data held in another. If the userUID in my attendance collection equals the userUID in my student collection I would like to retrieve the name of the student. Is this possible?
Asked
Active
Viewed 285 times
1
-
if you have a document with same userId in attendance and student collection, then you can query student using `WhereEqualTo(fieldName,value)` like `db.collection("student") .whereEqualTo("userId", "idValue").get()` – Mohammed Farhan Aug 20 '18 at 12:56
-
can I combine these queries of two collections into one query or how is this possible – Aug 20 '18 at 13:10
-
No its not possible to combine queries of two collection into one query. – Mohammed Farhan Aug 21 '18 at 04:43
2 Answers
0
This is currently not possible with Firestore. Firestore queries are limited to a documents in a single collection. You would have to perform multiple gets or queries.

Doug Stevenson
- 297,357
- 32
- 422
- 441
-
Is there anyway at all to query within a query even to try and retrieve this data and make a connection between the two collections. – Aug 20 '18 at 13:16
-
-
-
-
0
According to multiple Google Firebase engineers, querying across collections is not at all possible, despite the Firestore documentation that says:
If you need to query data across collections, use root-level collections.
https://firebase.google.com/docs/firestore/data-model?authuser=3
I would suggest that Google rewrite this part of their documentation because that sentences literally infers the opposite. It should read along the lines of:
If you need to query data across collections, not happening.

trndjc
- 11,654
- 3
- 38
- 51