title: TypeError: _Model2.default.aggregate(...).forEach is not a function
body: <p>When I am trying to iterate over the cursor I am getting following error</p>
  
  <pre><code>TypeError: _challengeModel2.default.aggregate(...).forEach is not a function
  </code></pre>
  
  <p>and here is my query</p>
  
  <pre><code>const completed = Challenge.aggregate([]).toArray()
  </code></pre>
  
  <p>can anyone please help me solve this and briefly explain about the cursor in mongodb</p>
  
  <p>I am using <strong>mongoose 5.x</strong> and <strong>mongodb 4.0</strong></p>