I have a structure of nested subcollections and documents. Each name of the documents in the experience
subcollection represents userId
of some user that has experience in that game.
I have a converted that attaches this userId
to the document:
experienceEntity.userId = snapshot.id;
experienceEntity.experience = snapshot.data().experience;
I want to query documents from all the experience
subcollections of all the games
that have a certain userId
. E.g. I want to get all documents having 400riCGTB0YkxAF52maPUr5jKPN2
ID from the screenshot above. I was trying this:
const result = await firestore()
.collectionGroup("experience")
.withConverter(gameExperienceEntityConverter)
.where("userId", "==", userId)
.get();
return result.docs.map((snap) => snap.data());
... but it returns an empty array. If I remove the where
clause - it returns all the documents from all experience
subcollections without any filtering (there can potentially be millions of those at this point).