0

I want to retrieve all members that have a particular ID in the array "types".

members in firestore:

{
  types: ["userId1", "userId2"]
}

security rules:

match /members/{types} {
  allow read, write: if get(/databases/$(database)/documents/members/$(types)).data.parents.hasAny([request.auth.uid]);

  allow read, write: if request.auth.uid in get(/databases/$(database)/documents/members/$(types)).data.parents;
}

Both get me access denied, help is appreciated.

Pancho
  • 68
  • 9
  • Please edit the question to show the query that isn't working the way you expect. We need to be able to see that the query matches the rules. – Doug Stevenson May 12 '20 at 16:07
  • db.collection("types").whereField("parents", arrayContains: userId).getDocuments() – Pancho May 13 '20 at 17:01
  • That query won't be matched by the rules you show here. It's querying a collection called "types", but your rules are defined to work with "members". – Doug Stevenson May 14 '20 at 16:04
  • You're right, my bad: db.collection("members").whereField("parents", arrayContains: userId).getDocuments() – Pancho May 15 '20 at 05:38

0 Answers0