Reputation: 2178
I have to check a document value != a string value in the Firebase Security rules. So I have to first check if the document exists and then check the value.
allow read: !get(path).data || get(path).data.value !== 'xyz';
As I am calling the get()
method twice, will it count 2 reads? If yes, how can I write the logic so that I fetch the document data once and reuse it?
Upvotes: 0
Views: 291
Reputation: 50830
As per the documentation, you are only charged once.
You are only charged one read per dependent document even if your rules refer to that document more than once.
Upvotes: 1