Firestore 规则 |在自定义函数中使用内置 get 函数时出错

Firestore Rules | getting error on using built-in get function in a custom function

我找不到在规则中获取内置 get 函数的方法。

我尝试制作一个简单的管道来调用 3 个函数:

isAllowedToCRUD(getClubData(getEventData(eventId).club_id) .id)

但是在 isAllowedToCRUD 中我得到以下错误:

错误 运行 模拟 — 错误:simulator.rules 行 [],列 []。找不到函数错误:名称:[get].;错误:提供给调用的参数无效。函数:[get],参数:["||invalid_argument||"](查看过时模拟)

规则:

 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)

        }
   }

有什么想法吗?

伙计们,有时候您需要呼吸新鲜空气来保持逻辑思维!

数据尚不存在,无法检查!

我将代码更改为:

 function isAllowedToCRUD(club_id){
    let checkClubId = IsUserIdExistsInClubs(request.auth.uid).club_id;
     return checkClubId == club_id;
}

 match /events/{eventId} {
  allow read, list: if true;
  allow create,write, update, delete: if isAllowedToCRUD(request.resource.data.club_id);
  
 
}