AbstractPipeline¶
abstract class AbstractPipeline<Output : Any>(val context: BsonContext, val chain: PipelineChainLink) : Pipeline<Output>
Helper class to implement Pipeline.
Notes for implementors¶
When implementing a new type of pipeline, the main requirement is to override the return tpe of all existing stage methods to return the same type as the current instance. This sadly has to be done manually because Kotlin doesn't have self-types.
When overriding the stage methods, avoid doing anything other than down-casting the resulting pipeline.
You will also need to implement withStage. Note how creating an instance of AbstractPipeline requires passing a PipelineChainLink. PipelineChainLink implements all complex methods from Pipeline for you.
Constructors¶
AbstractPipeline¶
constructor(context: BsonContext, chain: PipelineChainLink)
Properties¶
chain¶
Internal representation of the pipeline state.
context¶
@LowLevelApi
open override val context: BsonContext
The context used to generate this pipeline.
Can be accessed within children expressions.
Functions¶
toString¶
unsafeCast¶
abstract fun <New : Any> unsafeCast(): Pipeline<New>
Changes the type of the returned document, with no type-safety.
Every subsequent step in the pipeline will think the returned document is of type New. It is your responsibility to ensure that this corresponds to the reality; the KtMongo DSL makes no verifications.
If you want to edit the representation of the documents in the pipeline, prefer using HasProject.project.
See also
withStage: Add a new stage to this pipeline.
withStage¶
@DangerousMongoApi
@LowLevelApi
abstract override fun withStage(stage: BsonNode): Pipeline<Output>
Creates a new pipeline that expands on the current one by adding stage.
For usage documentation, see Pipeline.withStage.
Notes for implementors
A typical pipeline implementation will look like:
writeTo¶
@LowLevelApi
override fun writeTo(writer: BsonValueWriter)
Writes the entire pipeline into writer.
This function is similar to BsonNode.writeTo, with the difference that expressions generate documents, and pipelines generate arrays.
Using this method will thus write an array containing the different stages.