I have collections named quests
and quizzes
, which have sub-collections inside their documents named published
which will contain different published versions of the corresponding document.
- quests/
- published/
- quizzes/
- published/
quests
and quizzes
are also tagged and these tags are copied to published document. So all published documents have a tags
field(an Array of Strings).
I want to query all the published quests which are related to given tag. Something along this
db
.collectionGroup('published')
// This query is not correct, regex syntax doesn't work here for path.
// I have added it to show that I want to query only the published
// documents inside quests.
.where(
firebase.firestore.FieldPath.documentId(),
'==',
'/quests/*/published/*'
)
.where(
'tags',
'array-contains',
'kinematics'
)
--- EDIT ---
this is structure of quests
, and quizzes
also has the same structure.
and it also has tags field.
I want to fetch all the published quests that are related some particular tag, so here quests//published/2.0 should be one of the resulting documents, if I query with 'physics' tag, as version 1.0 it is not related only to 'kinematics'. Screenshot of only one quest is added here. there are multiple quests with multiple published version inside them relating to tag I want to query. I want to fetch all of them, excluding documents from quizzes//published/ with a single query.