I have a problem with creating rules in firestore.
This is my example: collection "users" -> many docs -> not every doc has inside, the subcollection with name "recipes". If subcollection "recipes" exists then it has docs with some data. One of them is "public" with type of boolean.
My problem: I want to get all recipes from all users, if condition of "public" is true.
Im stack at rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if request.auth != null && request.auth.uid == userId;
allow write: if request.auth != null && request.auth.uid == userId;
match /recipes/{recipeId} {
allow read: if resource.data.public == "true";
}
}
}
}
And it shows me: Error: simulator.rules line [9], column [21]. Null value error.
In this case, how should I get/call this data with clean javascript? If i just get some scripts like firebase.firestore() or firebase.auth().

