I am using Firestore rules and want to call get()
/exist()
in a function, and after that I call that function in subcollection. But it will give error:
Error running simulation — An unknown error occurred (viewing outdated simulation)
Can you please help out to point my mistake?
When I try allow create: if get(/databases/{database}/documents/Attendants/$(request.auth.uid).data.UserID)!=request.auth.uid
it will give following error:
Error running simulation — Error: simulator.rules line [12], column [31]. Function not found error: Name: [get].; Error: Invalid argument provided to call. Function: [get], Argument: ["||invalid_argument||"] (viewing outdated simulation)
When I follow this document https://firebase.google.com/docs/firestore/manage-data/transactions and try exist():
exists(/databases/{database}/documents/admins/$(request.auth.uid)); still not works.
I tried different path in exists and get function even I try full path then it works fine.
get(/databases/$(database)/documents/GroupExperiences/Experience/PrivateExperience/XmZPoKKQuZBeP68KAIJl/Admins/it07).data
match /PrivateExperience/{Experience}
{
function isAdmin()
{
//return true;
return exists(/databases/$(database)/documents/Admins/$(request.auth.uid));
}
function isAttendant()
{
return exists(/databases/$(database)/documents/Attendants/$(request.auth.uid));
}
allow create: if request.auth == null;
match /Activities/{Activity=**}
{
allow create: if (isAdmin() || isAttendant());
}
}