for example in Firstore
i have collection called products
and every doc has boolen field called isAllow : false
now in Security Firstore Rules How to make users can read only the docs with true value of isAllow field
and the same with write .. i read the documentation but couldn't understand exactly what i want
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
Yes,
match /collection/{document} {
allow read: if resource.data.isAllow == true;
}
Here resource.data
is a map of all of the fields and values stored in the document and the above rule will allow read operation only when isAllow field in the document being accessed is true.