2

I'm having an issue with the firebase security rule simulator, where I can't read whether a field exists. My structure is as follows, where meta is a subcollection of teams, and each team is in the teams collection.

{
  "teams": {
    <TEAM_ID>" {
      "name": "Team One"
      "meta": {
        "users": [<SOME USER UID>],
        "admins": [<SOME UID>]
      }
    }
  }
}

Basically I only want them to be able to read if there user id is in meta.users.

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /teams/{teamId} {
     allow read: if exists(/databases/$(database)/documents/teams/$(teamId)/meta/users/$(request.auth.uid))
   }
  }
}

But the above rules returns the following error.

Error running simulation — Error: simulator.rules line [5], column [21]. Function not found error: Name: [exists].

Soni Sol
  • 2,367
  • 3
  • 12
  • 23
George Kemp
  • 541
  • 1
  • 7
  • 21
  • [here](https://stackoverflow.com/questions/55955938/function-not-found-error-name-get-in-firestore-security-rules-simulation) there is a similar issue with a work around, coul you please confirm if the work around worked for you? – Soni Sol Nov 30 '19 at 01:23

0 Answers0