AggregateOperation constructor

AggregateOperation(
  1. Object pipeline, {
  2. DbCollection? collection,
  3. Db? db,
  4. bool? explain,
  5. Map<String, Object>? cursor,
  6. String? hint,
  7. Map<String, Object>? hintDocument,
  8. AggregateOptions? aggregateOptions,
  9. Map<String, Object>? rawOptions,
})

Implementation

AggregateOperation(Object pipeline,
    {DbCollection? collection,
    Db? db,
    bool? explain,
    Map<String, Object>? cursor,
    this.hint,
    this.hintDocument,
    AggregateOptions? aggregateOptions,
    Map<String, Object>? rawOptions})
    : cursor = cursor ?? <String, Object>{},
      explain = explain ?? false,
      super(
          collection?.db ?? db,
          <String, Object>{
            ...?aggregateOptions?.getOptions(collection?.db ?? db),
            ...?rawOptions
          },
          collection: collection,
          aspect: Aspect.readOperation) {
  if (pipeline is List<Map<String, Object>>) {
    this.pipeline = <Map<String, Object>>[...pipeline];
  } else if (pipeline is AggregationPipelineBuilder) {
    this.pipeline = pipeline.build();
  } else {
    throw MongoDartError('Received pipeline is "${pipeline.runtimeType}", '
        'while the method only accept "AggregationPipelineBuilder" or '
        '"List<Map<String, Object>>" objects');
  }
}