Lookup.withPipeline constructor

Lookup.withPipeline({
  1. required String from,
  2. required Map<String, dynamic> let,
  3. required List<AggregationStage> pipeline,
  4. required String as,
})

Creates $lookup stage with it's own pipeline

  • from - Specifies the collection in the same database to perform the join with. The from collection cannot be sharded.
  • let - Optional. Specifies variables to use in the pipeline field stages. Use the variable expressions to access the fields from the documents input to the $lookup stage. The pipeline cannot directly access the input document fields. Instead, first define the variables for the input document fields, and then reference the variables in the stages in the pipeline. To access the let variables in the pipeline, use the $expr (Expr) operator.

NOTE:

The let variables are accessible by the stages in the pipeline, including additional $lookup stages nested in the pipeline.

  • pipeline - Specifies the pipeline to run on the joined collection. The pipeline determines the resulting documents from the joined collection. To return all documents, specify an empty pipeline [].

The pipeline cannot include the $out stage or the $merge stage.

The pipeline cannot directly access the input document fields. Instead, first define the variables for the input document fields, and then reference the variables in the stages in the pipeline.

  • as - Specifies the name of the new array field to add to the input documents. The new array field contains the matching documents from the from collection. If the specified name already exists in the input document, the existing field is overwritten.

Implementation

Lookup.withPipeline(
    {required String from,
    required Map<String, dynamic> let,
    required List<AggregationStage> pipeline,
    required String as})
    : super(
          'lookup',
          AEObject({
            'from': from,
            'let': AEObject(let),
            'pipeline': AEList(pipeline),
            'as': as
          }));