I am aware it is not a RS directly related question, but I want to find a solution or approach integrated into it and I know there are several users working in projects with Firestore so maybe someone could help me figure this out.
I am trying to find an approach to get something that is not possible as it is. Firestore does not allow two “array-contain” in a query, but there must be a way to get what I am looking for. Maybe changing the way I am saving the data.
My project is linked to a database in Firestore where there are two collections:
students (collection) - student1ID (document) + name (string) + more data (string) + teachers (array of teacher1ID, teacher2ID...) + subjects (array of Maths and English) - student2ID (document) + name (string) + more data (string) + teachers (array of teacher1ID, teacher2ID...) + subjects (array of Maths and Spanish) teachers (collection) - teacher1ID (document) + name (string) + more data (string) + students (array of student1ID, student3ID...)
It is quite simplified but just to get the idea. The user of the project is the teacher. In order to set grades for his students -llisted in the array in his own document- I have created a query for all students where the array contains the subject selected, and then some = clauses but still, the result of the query may give students that are not from that teacher because there will probably be more math teachers.
An ideal query would be to get documents (‘subjects’,‘array-contains’,‘math’) && (‘teachers’,‘array-contains’,‘student1ID’). That way, student 2 wouldn’t be listed even though he/she studies Math.
I hope I explained it properly. Thanks!