title: how to call count operation after find with mongodb java driver
body: <p>I am using MongoDB 3.0. suppose there is a set of documents named <code>photos</code>, its structure is </p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>{"_id" : 1, photographer: "jack"}
  </code></pre>
  
  <p>with <code>database.getCollection("photos")</code>, Mongodb will return a <code>MongoCollection</code> object, on which I have the method <code>count()</code> to get the number documents returned. </p>
  
  <p>However, when I make queries with specific conditions. For example find documents with id smaller than 100 : </p>
  
  <pre class="lang-js prettyprint-override"><code>photosCollections.find(Document.parse("{_id : {$lt : 100}}"))
  </code></pre>
  
  <p>Above <code>find</code> method will always return a cursor which doesn't provide a <code>count()</code> function. So how can I know how many documents returned ? I know on command line, I can use </p>
  
  <pre class="lang-js prettyprint-override"><code>db.photos.find({_id : {$lt : 100}}).count()
  </code></pre>
  
  <p>Of course, I can go through the iterator and count the number of documents myself. However I find it really clumsy. I am wondering does MongoDB java driver provides such functionality to count the number of documents returned by the <code>find()</code> method ? If not, what is the reason behind the decision ? </p>