Using the following Security Rule as an example:
service cloud.firestore {
match /databases/{database}/documents {
// Allow the user to read data if the document has the 'visibility'
// field set to 'public'
match /cities/{city} {
allow read: if resource.data.visibility == 'public';
}
}
}
Will requests to read a document in this collection, for example cities/SF
, count against the Firestore Account's read limits if the condition is false for the resource?
For instance, say the resource.data.visibility property is set to 'private' for cities/SF
and a read request is made for the document. Can this read request be made an unlimited number of times, without incurring costs on the account? Or does the evaluation of the rule itself count as a read?
CodePudding user response:
Whenever you are using resource
in your rules it will cost at most one read and it will counted against the usage quota.
See the docs at:
The resource variable https://firebase.google.com/docs/rules/rules-language