aggregate method

Future<Map<String, dynamic>> aggregate(
  1. List pipeline, {
  2. bool allowDiskUse = false,
  3. Map<String, Object>? cursor,
})

Old version to be used on MongoDb versions prior to 3.6

Implementation

Future<Map<String, dynamic>> aggregate(List pipeline,
    {bool allowDiskUse = false, Map<String, Object>? cursor}) {
  if (db.masterConnection.serverCapabilities.supportsOpMsg) {
    return AggregateOperation(
      pipeline,
      collection: this,
      cursor: cursor,
      aggregateOptions: AggregateOptions(allowDiskUse: allowDiskUse),
    ).execute();
  }
  var cmd = DbCommand.createAggregateCommand(db, collectionName, pipeline,
      allowDiskUse: allowDiskUse, cursor: cursor);
  return db.executeDbCommand(cmd);
}