MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation • Pipeline
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 <strong>withStage</strong>
or <strong>reinterpret</strong>
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¶
- Output
-
The type of document that this pipeline results in. Changing this type is possible by calling
reinterpret
.
Inheritors¶
Properties¶
context
¶
abstract val context:
The context used to generate this pipeline.
Functions¶
reinterpret
¶
abstract fun <New : Any> reinterpret(): Pipeline<New>
Changes the type of the returned document, with no type-safety.
toString
¶
JSON representation of this pipeline.
withStage
¶
Creates a new pipeline that expands on the current one by adding stage
.
writeTo
¶
abstract fun writeTo(writer: )
Writes the entire pipeline into writer
.