title: Find and count nodejs mongodb
body: <p>I have mongodb collection with data e.g.</p>
  
  <pre><code>{"test": "test1"} 
  {"test": "test2"}
  {"test": "test3"}
  </code></pre>
  
  <p>From the database level it searches without a problem:</p>
  
  <pre><code>db.collection.find({test: "test1"}).count();
  </code></pre>
  
  <p>Gets the result: 13</p>
  
  <p>However, from the nodejs level when I have:</p>
  
  <pre><code>    var counter = db.collection('collection').find({test: "test1"}).count();
      counter.forEach (function (doc, err) {
           assert.equal (null, err);
           resultArray.push (doc);
       }, function () {
           client.close ();
           console.log ("resultArray", resultArray);
       });
  </code></pre>
  
  <p>Result: forEach is not a function</p>
  
  <p>What should I use so that I can then display this value in EJS</p>
  
  <p>Best regards</p>