title: Aggregate is not a function - Mongoose Nodejs
body: <p>Can somebody help me to fix this, here is my code for aggregate from mongoose:</p>
  
  <pre><code>export class GetVehiclesbyKotaCommandHandler {
  constructor(namaKota) {
      return new Promise((resolve, reject) =&gt; {
          VehiclesDB.find().populate({
              path: 'mitraId',
              model: 'RentalDB',
              select: 'namaKota'
          }).aggregate([
              {
                  $match : {
                      namaKota:namaKota
                  }
              }
              ]).lean().then((dataVehicles)=&gt;{
              if(dataVehicles !== null){
                  resolve(dataVehicles);
              } else {
                  reject (new NotFoundException('Couldn\'t find any Vehicles with namaKota' + namaKota));
              }
          }).catch((errDataVehicles)=&gt;{
              reject(new CanNotGetVehiclesException(errDataVehicles.message));
          });
      });
  }}
  </code></pre>
  
  <p>And I get an error like this on the console:</p>
  
  <pre><code>TypeError: _VehiclesDB2.default.find(...).populate(...).aggregate is not a function
  </code></pre>
  
  <p>DONE, I Thanks for Hana :)
  And i change my mitraId type ObjectId
      mitraId : {
         type:  Schema.Types.ObjectId,
          required: true
      },</p>