Pipeline
A multi-stage pipeline that performs complex operations on MongoDB.
Similar to Sequence and Flow, but executed by MongoDB itself.
MongoDB has different types of pipelines with different available operators, which are represented by the different implementations of this interface.
Instances of this class are immutable.
Stages
A pipeline is composed of stages, each of which transforms the data in some way. For example, some stages filter information out, some stages add more information, some stages combine documents, some stages extract information from elsewhere, etc.
Each stage is defined as an extension function on this class. Note that as mentioned, not all stages are available for all pipeline types. The following stages are available:
If you can't find a stage you're searching for, visit the tracking issue.
Implementing a new stage
Just like operators, stages can be added as extension methods on this type or any of its subtypes. To register the stage, call withStage, optionally followed by reinterpret, and return the resulting pipeline.
Stages should return Pipeline instances that were generated by the withStage or reinterpret methods. Pipeline implementations are allowed to assume all stages they will be provided were generated by their own implementation of these methods, and thus may downcast the resulting pipeline to another type safely. Returning any other Pipeline instance has unspecified behavior.
External resources
Parameters
The type of document that this pipeline results in. Changing this type is possible by calling reinterpret.