I am really stuck using Firestore for my backend. Since every single DB design, I try ends with Firebase not allowing almost any combination of subqueries or nested filtering I need.
The domain is simple I have courses which has categories and languages, and I want to filter those courses by category and language.
What I have tried so far:
collections:
[
courses,
categories,
languages,
]
document samples:
course
{
id: 'pQYYsU80iLgZqTiYLkJXwHL25873',
title: 'Javascript II',
teacherName: 'Bob',
categories: ['javascript','nodejs'],
languages: ['english','spanish']
}
category
{
id: 'QJMzrwEJ6vRtPBsfSOVxojTMuHk1',
name: 'programming',
subcategories: ['programming','javascript','php','nodejs'],
keywords: ['computer', 'developing', 'web', 'developer', 'programming','javascript','php','nodejs']
}
language
{
id: 'AbMzrwC6vRRPBsfSOVx2jTMuHk1',
name: 'english',
code: 'en-US',
}
I want to query, i.e.: all the courses about 'javascript' and available in 'english'. But it is impossible to fetch them in a single query as array-contains cannot be nested multiple times.
I cannot do it by fetching multiple queries as the device runs out of memory very quickly.
Is there any domain design alternative to achieve this in a single query?