Reputation: 1
I am using flutter for mobile development and I need to query an map on array in firestore.
My code :
FirebaseFirestore.instance
.collection("/notes")
.where({
"semester 1"
}, arrayContains: [
{"ec321ece"}
], isNotEqualTo: [
{"value321ece"}
])
.snapshots()
.listen((value) => value.docs.forEach((element) {
print("${element.data()}");
}));
Please help me.
Upvotes: 0
Views: 401
Reputation: 4898
It is not possible to use array contains with maps, in the way that you are trying. There are a couple of options:
Have your existing semester 1
array with the maps, but also add a second array called Semester 1 IDs
and store only the values (as strings) that you want to search for.
Using a semesters
sub-collection of your notes
document will give you greater flexibility in your searching. Also, if your notes
document grows as you add more semesters, it may get bigger than 1MB and will be a heavy payload if listing notes in your UI.
Upvotes: 1