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].