I couldn't find a way to getting build-in get function in Rules.
I tried to make a simple pipeline to call 3 functions:
isAllowedToCRUD(getClubData(getEventData(eventId).club_id).id)
but in isAllowedToCRUD I getting below error:
Error running simulation — Error: simulator.rules line [], column []. Function not found error: Name: [get].; Error: Invalid argument provided to call. Function: [get], Argument: ["||invalid_argument||"] (viewing outdated simulation)
rules:
service cloud.firestore {
match /databases/{database}/documents {
function isAllowedToCRUD(club_id){
return IsUserIdExistsInClubs(request.auth.uid).club_id == club_id
}
function getClubData(clubId){
return get(/databases/$(database)/documents/clubs/$(clubId))
}
function IsUserIdExistsInClubs(clubUserId){
// Getting error here!
let personInCharge = get(/databases/$(database)/documents/persons_in_charge/$(clubUserId));
return personInCharge.data
}
match /events/{eventId} {
allow read, list: if true;
allow write,create, update, delete: if
isAllowedToCRUD(getClubData(getEventData(eventId).club_id).id)
}
}
Any Idea?