title: Firestore security rule get() not work
body: <h1>The solution is in the end of the post. Check it out.</h1>
  
  <h1>Решение проблемы в конце поста. Дочитайте.</h1>
  
  <p>just a simple question: whats wrong with this and why this is not working?</p>
  
  <p>Trying to get access with user who has role 'admin' in users section to the <strong>/titles/{anyTitle}</strong> but still get </p>
  
  <blockquote>
    <p><strong>Missing or insufficient permissions</strong>.</p>
  </blockquote>
  
  <pre><code>service cloud.firestore {
    match /databases/{database}/documents {
      match /{document=**} {
        allow write: if false;
        allow read: if false;
      }
      function userCanWrite () {
        return get(/databases/{database}/documents/users/$(request.auth.uid)).data.role == "admin";
      }
      match /titles/{anyTitle=**} {
        allow read: if request.auth != null;
        allow write: if userCanWrite();
      }
    }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/j30cP.png" rel="noreferrer">Here is my database structure</a></p>
  
  <h2><strong>P.S.</strong></h2>
  
  <p>I tried another rule from official documents
  <code>get(/databases/{database}/documents/users/$(request.auth.uid‌​)).data.isAdmin == true;</code></p>
  
  <p>and this is not working too</p>
  
  <h1>UPDATE: CORRECT WAY TO DO IT</h1>
  
  <p>Support helped me find the solution
  this is how you should do:</p>
  
  <p><strong>db structure:</strong></p>
  
  <blockquote>
    <p>users -> {{ userid }} -> { role: "admin" }</p>
  </blockquote>
  
  <p><strong>database rule settings:</strong></p>
  
  <blockquote>
    <p>get(usersPath/$(request.auth.uid)).role == "admin" || get(usersPath/$(request.auth.uid)).data.role == "admin";</p>
  </blockquote>