title: Mongoose Aggregation not working, tried different ways still not able to solve the problem, even dont know what is problem
body: <p>I am new to node and mongoose. Tried many ways though none worked for me.</p>
  
  <ol>
  <li><strong>Aggregate query on mongo shell is working, here is query</strong>:- </li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>db.collection.aggregate([
    {
      $match: {
        p_id: ObjectId("5d8b4f24d86d9f2400d7ff46"),
        m_id: { $in: [ObjectId("5dde14b3f34ac02500a2b0aa")] }
      }
    },
    { $sort: { updated_at: 1 } },
    { $group: { _id: "$m_id", evaluation: { $last: "$evaluation" } } }
  ]);
  </code></pre>
  
  <ol start="2">
  <li><strong>Aggregate query in mongoose</strong>:-</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>Model.aggregate([
    { $match: { p_id: pId, m_id: { $in: mIds } } },
    { $sort: { updated_at: 1 } },
    {
      $group: {
        _id: "$m_id",
        evaluation: { $last: "$evaluation" }
      }
    }
  ]);
  </code></pre>
  
  <p>Error:-  <strong>throwing cursor option is required</strong></p>
  
  <ol start="3">
  <li><strong>Aggregate query after adding cursor optionr:-</strong></li>
  </ol>
  
  <p>Query:-</p>
  
  <pre class="lang-js prettyprint-override"><code>Model.aggregate(
    [
      { $match: { p_id: pId, m_id: { $in: mIds } } },
      { $sort: { updated_at: 1 } },
      {
        $group: {
          _id: "$m_id",
          evaluation: { $last: "$evaluation" }
        }
      }
    ],
    { cursor: {} }
  );
  </code></pre>
  
  <p>Error: - <strong>error_stack=Error: Arguments must be aggregate pipeline operators</strong></p>
  
  <ol start="4">
  <li><strong>Mongoose aggregate api fluent returning aggregationcursor but on doing aggregationcursor.next() a promise is returned in pending state. After adding then() on aggregationcursor.next() a null object is returned:-</strong></li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>Model.aggregate()
    .match({ p_id: pId, m_id: { $in: mIds } })
    .sort({ $updated_at: 1 })
    .group({
      _id: "$m_id",
      evaluation: { $last: "$evaluation" }
    })
    .cursor({ batchSize: 1000 });
  </code></pre>
  
  <p>Schema:</p>
  
  <pre class="lang-js prettyprint-override"><code>const PSchema = new Schema({
    m_id: { type: Schema.Types.ObjectId },
    p_id: { type: Schema.Types.ObjectId },
    evaluation: { type: String, enum: _.values(EvaluationType) },
    created_at: { type: Date },
    updated_at: { type: Date }
  });
  </code></pre>
  
  <blockquote>
  <pre><code>Mongo/Mongoose version:-
  "@types/mongoose": "^3.8.36",
  "mongodb": "^3.3.5",
  "mongoose": "~4.5.9",
  </code></pre>
  </blockquote>