title: Firestore security rules get field/id of reference
body: <p>I have  two collections - tenancies and users.</p>
  
  <p>A tenancy doc has a field called "landlordID" and is of type REFERENCE (not String).</p>
  
  <p>Now in my Firestore Security Rules I want to allow a tenancy to be updated ONLY IF the landlordID field of that tenancy matches with the uid of the user making the request, namely <code>request.auth.uid</code>. </p>
  
  <p>Read it as " allow a tenancy document to be updated if the user making the user is authenticated, hence request.auth.uid != null, and the landlordID field's ID should be equal to that of the request.auth.uid.</p>
  
  <p>Hence the code should me something like this:</p>
  
  <pre><code>    service cloud.firestore {
  
        match /databases/{database}/documents {
  
          match /tenancies/{tenancyID}{
  
              allow update: if request.auth.uid != null &amp;&amp; 
                          request.auth.uid == get(resource.data.landlordID).id
      }
  
  }
  </code></pre>
  
  <p>I have also tried <code>get(/databases/$(database)/documents/users/$(resource.data.landlordID)).data.id</code></p>
  
  <p>Supporting screenshot of my database</p>
  
  <p><a href="https://i.stack.imgur.com/p0OX3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/p0OX3.png" alt="enter image description here"></a></p>
  
  <p>This should be very simple but  get() simply does not work. <a href="https://firebase.google.com/docs/firestore/security/rules-conditions" rel="noreferrer">Firebase Docs, scroll to "Access other documents"</a> was not helpful at all for my situation and I am not sure how to get it working.</p>
  
  <p>It would be a shame if references can't be used like this as they are just like any other field of a document.</p>