Trying to query across collections in google Firestore
up vote
1
down vote
favorite
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?
firebase google-cloud-firestore
add a comment |
up vote
1
down vote
favorite
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?
firebase google-cloud-firestore
if you have a document with same userId in attendance and student collection, then you can query student usingWhereEqualTo(fieldName,value)
likedb.collection("student") .whereEqualTo("userId", "idValue").get()
– Mohammed Farhan
Aug 20 at 12:56
can I combine these queries of two collections into one query or how is this possible
– Sean Gallagher
Aug 20 at 13:10
No its not possible to combine queries of two collection into one query.
– Mohammed Farhan
Aug 21 at 4:43
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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?
firebase google-cloud-firestore
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?
firebase google-cloud-firestore
firebase google-cloud-firestore
edited Aug 20 at 12:54
Doug Stevenson
65.7k77997
65.7k77997
asked Aug 20 at 12:37
Sean Gallagher
406
406
if you have a document with same userId in attendance and student collection, then you can query student usingWhereEqualTo(fieldName,value)
likedb.collection("student") .whereEqualTo("userId", "idValue").get()
– Mohammed Farhan
Aug 20 at 12:56
can I combine these queries of two collections into one query or how is this possible
– Sean Gallagher
Aug 20 at 13:10
No its not possible to combine queries of two collection into one query.
– Mohammed Farhan
Aug 21 at 4:43
add a comment |
if you have a document with same userId in attendance and student collection, then you can query student usingWhereEqualTo(fieldName,value)
likedb.collection("student") .whereEqualTo("userId", "idValue").get()
– Mohammed Farhan
Aug 20 at 12:56
can I combine these queries of two collections into one query or how is this possible
– Sean Gallagher
Aug 20 at 13:10
No its not possible to combine queries of two collection into one query.
– Mohammed Farhan
Aug 21 at 4:43
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 at 12:56
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 at 12:56
can I combine these queries of two collections into one query or how is this possible
– Sean Gallagher
Aug 20 at 13:10
can I combine these queries of two collections into one query or how is this possible
– Sean Gallagher
Aug 20 at 13:10
No its not possible to combine queries of two collection into one query.
– Mohammed Farhan
Aug 21 at 4:43
No its not possible to combine queries of two collection into one query.
– Mohammed Farhan
Aug 21 at 4:43
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
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.
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.
– Sean Gallagher
Aug 20 at 13:16
As I said, write multiple queries to get the data you need.
– Doug Stevenson
Aug 20 at 13:20
is there anyway to write a function within a query to retrieve data maybe.
– Sean Gallagher
Aug 20 at 13:56
No, you have to perform multiple queries.
– Doug Stevenson
Aug 20 at 13:58
And to add to this is there any way to write queries within other queries
– Sean Gallagher
Aug 20 at 14:22
add a comment |
up vote
0
down vote
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.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
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.
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.
– Sean Gallagher
Aug 20 at 13:16
As I said, write multiple queries to get the data you need.
– Doug Stevenson
Aug 20 at 13:20
is there anyway to write a function within a query to retrieve data maybe.
– Sean Gallagher
Aug 20 at 13:56
No, you have to perform multiple queries.
– Doug Stevenson
Aug 20 at 13:58
And to add to this is there any way to write queries within other queries
– Sean Gallagher
Aug 20 at 14:22
add a comment |
up vote
0
down vote
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.
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.
– Sean Gallagher
Aug 20 at 13:16
As I said, write multiple queries to get the data you need.
– Doug Stevenson
Aug 20 at 13:20
is there anyway to write a function within a query to retrieve data maybe.
– Sean Gallagher
Aug 20 at 13:56
No, you have to perform multiple queries.
– Doug Stevenson
Aug 20 at 13:58
And to add to this is there any way to write queries within other queries
– Sean Gallagher
Aug 20 at 14:22
add a comment |
up vote
0
down vote
up vote
0
down vote
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.
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.
answered Aug 20 at 12:56
Doug Stevenson
65.7k77997
65.7k77997
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.
– Sean Gallagher
Aug 20 at 13:16
As I said, write multiple queries to get the data you need.
– Doug Stevenson
Aug 20 at 13:20
is there anyway to write a function within a query to retrieve data maybe.
– Sean Gallagher
Aug 20 at 13:56
No, you have to perform multiple queries.
– Doug Stevenson
Aug 20 at 13:58
And to add to this is there any way to write queries within other queries
– Sean Gallagher
Aug 20 at 14:22
add a comment |
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.
– Sean Gallagher
Aug 20 at 13:16
As I said, write multiple queries to get the data you need.
– Doug Stevenson
Aug 20 at 13:20
is there anyway to write a function within a query to retrieve data maybe.
– Sean Gallagher
Aug 20 at 13:56
No, you have to perform multiple queries.
– Doug Stevenson
Aug 20 at 13:58
And to add to this is there any way to write queries within other queries
– Sean Gallagher
Aug 20 at 14:22
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.
– Sean Gallagher
Aug 20 at 13:16
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.
– Sean Gallagher
Aug 20 at 13:16
As I said, write multiple queries to get the data you need.
– Doug Stevenson
Aug 20 at 13:20
As I said, write multiple queries to get the data you need.
– Doug Stevenson
Aug 20 at 13:20
is there anyway to write a function within a query to retrieve data maybe.
– Sean Gallagher
Aug 20 at 13:56
is there anyway to write a function within a query to retrieve data maybe.
– Sean Gallagher
Aug 20 at 13:56
No, you have to perform multiple queries.
– Doug Stevenson
Aug 20 at 13:58
No, you have to perform multiple queries.
– Doug Stevenson
Aug 20 at 13:58
And to add to this is there any way to write queries within other queries
– Sean Gallagher
Aug 20 at 14:22
And to add to this is there any way to write queries within other queries
– Sean Gallagher
Aug 20 at 14:22
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
up vote
0
down vote
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.
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.
answered Nov 11 at 1:31
narddog
1,764620
1,764620
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51930931%2ftrying-to-query-across-collections-in-google-firestore%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
if you have a document with same userId in attendance and student collection, then you can query student using
WhereEqualTo(fieldName,value)
likedb.collection("student") .whereEqualTo("userId", "idValue").get()
– Mohammed Farhan
Aug 20 at 12:56
can I combine these queries of two collections into one query or how is this possible
– Sean Gallagher
Aug 20 at 13:10
No its not possible to combine queries of two collection into one query.
– Mohammed Farhan
Aug 21 at 4:43