I want to do something like this:
firestore().collection('users').collection("account").where('email', '==', "[email protected]").get();
I want to get user's data among users who has a specific email. But the problem here is that the email is in a subCollection.
How to do it?
CodePudding user response:
That's the problem, in the current SDKs, you can't do this. you have to specify a full path, i.e :
collection1->doc->collection2.where(..etc
Would advise to move this key \email
to the doc in the first collection if it's that important. Otherwise, you have to run multiple chained queries. Or fetch all the docs in collection#1, then for each doc, run your where
query on every one of those docs and look into their subcollections, but it'll cost you lots of reads. Consider restructuring your data.