Fabian
Fabian

Reputation: 5650

Firestore security rules is supposed to have a values method

In the following documentation they reference a value method for the firestore security rules. I unfortunately could not get that working.

https://cloud.google.com/firestore/docs/solutions/role-based-access

function getRole() {
  // Read from the "roles" map in the story document.
  return value(/databases/$(database)/documents/stories/$(story)).roles[request.auth.uid];
}

What I could get working is this:

function getRole() {
  return resource.data.roles[request.auth.uid];
}

So I wonder why they don't use this simpler version? And if they would want to be more explicit, shouldn't they use the get method instead of value?

Upvotes: 2

Views: 422

Answers (1)

Dan McGrath
Dan McGrath

Reputation: 42048

I think this is old documentation from our alpha program which someone avoided our docs scrub for public beta. resource.data & get() are definitely what you want to use.

(We'll get it updated :))

Upvotes: 1

Related Questions