I am trying to build a Firestore query in flutter which filters restaurant results based on the cuisine requested.
Based on the answer from Firestore query where map contains string by Lucas Aschenbach, I have designed my database so that the cuisines are listed in a common sub-collection
and my query is:
final Query locations = FirebaseFirestore.instance
.collection('locations')
.where('cuisines.$id.exists', isEqualTo: true);
I have added read access to the sub-collection:
match /locations/{l} {
allow read: if true;
allow write: if request.auth.token.role == 'admin';
}
match /locations/{l}/cuisines {
allow read: if true;
allow write: if request.auth.token.role == 'admin';
}
The $id in my test case is "american"
...but... no results.
Does anyone see anything obviously wrong? Appreciated!