title: How to query Firestore from client?
body: <p>I am make security rule for Firebase app with authentication.</p>
  
  <p>I want only user be able access his own user document.</p>
  
  <p>I have this security rule:</p>
  
  <pre><code>  match /users/{uid} {
    allow read, update: if request.auth.uid == uid;
    allow create: if request.auth.uid != null;
    }
  </code></pre>
  
  <p>But when I run client code, it give error:</p>
  
  <blockquote>
    <p>[Firestore]: Status{code=PERMISSION_DENIED, description=Missing or
    insufficient permissions., cause=null}</p>
  </blockquote>
  
  <p>In client code I check if document with user uid already exist (if it not exist, I write data to firestore):</p>
  
  <pre><code>final QuerySnapshot result = await Firestore.instance
      .collection('users')
      .where('uid', isEqualTo: user.uid)
      .getDocuments();
  documents = result.documents;
  if (documents.isEmpty) {
  …
  </code></pre>
  
  <p>Why I get this error?</p>
  
  <p>I have read <a href="https://firebase.google.com/docs/firestore/security/rules-query" rel="nofollow noreferrer">https://firebase.google.com/docs/firestore/security/rules-query</a> and it say <code>db.collection("stories").where("author", "==", user.uid).get()</code> is valid. </p>