title: Firestore security rule get() not working
body: <p>In firestore I want a user to only access a document if the user is in the <code>teamid</code> mentioned in the document. Now I have a different collection called <code>teams</code> where I have users mapped as <code>{ user_id = true }</code>. So I have the following in the Firestore rules</p>
  
  <pre><code>return get(/databases/$(database)/documents/teams/$(resource.data.teamid)).data.approvedMembers[request.auth.uid] == true;
  </code></pre>
  
  <p>Now this rule does not work and fails any request made to the database by the frontend. But when I replace <code>$(resource.data.teamid)</code> with my actual <code>teamid</code> value as follows,</p>
  
  <pre><code>return get(/databases/$(database)/documents/teams/234234jk2jk34j23).data.approvedMembers[request.auth.uid] == true;
  </code></pre>
  
  <p>... it works as expected.</p>
  
  <p>Now my question is am I using <code>resource</code> in a wrong way or is <code>resource</code> not supported in <code>get()</code> or <code>exists()</code> queries in Firestore rules?</p>
  
  <p><strong>Edit</strong>
  Complete rules as follows</p>
  
  <pre><code>service cloud.firestore {
    match /databases/{database}/documents {
  
      function isTeamMember() {
          return get(/databases/$(database)/documents/teams/$(resource.data.teamid)).data.approvedMembers[request.auth.uid] == true;
          // return exists(/databases/$(database)/documents/teams/$(resource.data.teamid));
      }
  
      match /{document=**} {
          allow read, write: if isTeamMember();
      }
    }
  }
  </code></pre>
  
  <p>If you notice the commented out rule, <code>exists()</code> does not work in this case either.</p>