title: Firestore rule: match top level collection
body: <p>Setup:</p>
  
  <ul>
  <li>My top collection is named <code>users</code></li>
  <li>Each <code>user</code> is named for their unique ID, <code>uid</code></li>
  <li>I want to make a rule so that no matter what document or sub-collection is being accessed, if it will compare <code>uid</code> to the name of current <code>user</code> in users to allow</li>
  </ul>
  
  <p>Current attempt:</p>
  
  <ul>
  <li>Note that this WORKS for top level <code>documents</code>, but as soon as I try to work with a sub-collection within that user, it fails</li>
  <li><p>If it matters, there will be 7 named sub-collections that are always the same between users</p>
  
  <pre><code>rules_version = '2';
  service cloud.firestore {
    match /databases/{database}/documents {
      match /users/{user} {
        function isSignedIn() {
          return request.auth.uid != null;
        }
  
        allow read, write: if isSignedIn() &amp;&amp; request.auth.uid == user
      }
    }
  }
  </code></pre></li>
  </ul>
  
  <p>Any help would be appreciated. I think I need to add some ** somewhere?</p>