Reputation: 2432
I want to allow the family creator to add children. I´m saving the uid as the "owner" of the family
match /families/{family} {
allow create: if request.auth != null
allow update: if request.auth != null && request.auth.uid == request.resource.data.uid;
}
match /families/{family}/children/{child} {
allow read
allow create: if request.auth.uid != null //this will allow any parent to create children on any famly!!;
}
how can I allow create if {family}.uid == request.auth.uid ??
Upvotes: 0
Views: 174
Reputation: 317958
You will need to use get()
to access other documents other than the one being matched by the rule. For your case, that means you need to get()
the family document in order to use its field values.
match /families/{family}/children/{child} {
allow read;
allow create: if
get(/databases/$(database)/documents/families/$(family)).data.uid == request.auth.uid;
}
Upvotes: 2