Reputation: 1
I need a flutter query for getting data from firebase;
The query should go to User collection and search every document with UserType = 1 field. There is a "classes" collection in each document and each of "classes" have other documents such as "math", "music" etc. I need to get the document with the field classCode == myInput
QuerySnapshot query1 = await _fireStore.collection("Users").where(["userType"], isEqualTo: 1).get();
I don't know how to move from here.
Upvotes: 0
Views: 130
Reputation: 599776
You have two main options for implement this.
The first is pretty close to how you describe in your question:
classes
subcollection for the classCode
.The second approach makes use of a collection group query to:
classes
docs (across all the subcollections) with the searched user type.The best approach depends on mostly on what results you need. If you results are user documents, the first approach is usually pretty easy. If the results are classes
then I'd definitely try the second approach first.
Upvotes: 1