title: MongoDB count() versus countDocuments()
body: <p>I am using MongoDB and more specifically Mongoose.  I've recently been getting rid of some deprecation warnings from updating mongo and mongoose.</p>
  <p>Some of my queries might as shown:</p>
  <pre><code>const count = await Badge.find(query).count().exec()
  </code></pre>
  <p>I have since changed this to</p>
  <pre><code>const count = Badge.find(query).countDocuments().exec()
  </code></pre>
  <p>and viola the depracation warning is gone.  However, reading the documentation at MongoDB it seems that it should be written like this:</p>
  <pre><code>const count = Badge.countDocuments(query)
  </code></pre>
  <p>All of the above return the exact same thing.  Obviously the latter two are the ones I want because of the depracation of <code>count()</code>.</p>
  <p>What is the difference between the second two and should I prefer one over the other?</p>