title: How To Count Number of Documents in a Collection in Firebase Firestore With a WHERE query in react.js
body: <p>I want to get the total number of users in my Firebase Firestore collection. I can get it easily by writing this code:</p>
  <pre><code>const [totalUsers, setTotalUsers] = useState(0);
    const [newUsers, setNewUsers] = useState(0);
  
    useEffect(() =&gt; {
      firebase.firestore().collection(&quot;Users&quot;).get().then((querySnapshot) =&gt; {
        const TotalUsers = querySnapshot.size
          setTotalUsers(TotalUsers)
  
      })
    }, []);
  </code></pre>
  <p>But what i want is to get the total number of users with a condition such as the following:</p>
  <pre><code>   // this is not working, its not showing any results back.
    useEffect(() =&gt; {
      firebase.firestore().collection(&quot;Users&quot;).where(&quot;usersID&quot;,&quot;!=&quot;,&quot;101010&quot;).get().then((querySnapshot) =&gt; {
  
        querySnapshot.forEach((doc) =&gt; {
          const TotalUsers = doc.size
          setTotalUsers(TotalUsers)
        })
        
  
      })
    }, []);
  </code></pre>
  <p>But the above code is not working and isn't returning any results.</p>
  <p>How can I get the total number of documents in a collection in firebase firestore with a where query?</p>