简体   繁体   中英

Firestore Security Rules and Read Limits

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM