title: MongoDB ODM SELECT COUNT(*) equivalent
body: <p>I wonder if there is an equivalent to the MySQL-Query:</p>
  
  <pre class="lang-sql prettyprint-override"><code>   SELECT COUNT(*) FROM users
  </code></pre>
  
  <p>in MongoDB ODM?</p>
  
  <p>This might work:</p>
  
  <pre class="lang-php prettyprint-override"><code>$qb = $this-&gt;dm-&gt;createQueryBuilder('Documents\Functional\Users');
  $qb-&gt;select('id');   
  $query   = $qb-&gt;getQuery();
  $results = $query-&gt;execute();
  echo $query-&gt;count(); 
  </code></pre>
  
  <p>But aren't then all IDs returned and how does this affect performance if there are more complex documents in database. I don't want too send to much data around just to get a count. </p>