aggregate

abstract fun aggregate(pipeline: List<Bson>): AggregateFlow<TDocument>

Aggregates documents according to the specified aggregation pipeline. If the pipeline ends with a $out stage, the returned iterable will be a query of the collection that the aggregation was written to. Note that in this case the pipeline will be executed even if the iterable is never iterated.

Return

an iterable containing the result of the aggregation operation

Parameters

pipeline

the aggregate pipeline


abstract fun <TResult : Any> aggregate(pipeline: List<Bson>, resultClass: KClass<out TResult>): AggregateFlow<TResult>

Aggregates documents according to the specified aggregation pipeline. If the pipeline ends with a $out stage, the returned iterable will be a query of the collection that the aggregation was written to. Note that in this case the pipeline will be executed even if the iterable is never iterated.

Return

an iterable containing the result of the aggregation operation

Parameters

pipeline

the aggregate pipeline

resultClass

the class to decode each document into

the target document type of the iterable.

abstract fun aggregate(clientSession: ClientSession, pipeline: List<Bson>): AggregateFlow<TDocument>

Aggregates documents according to the specified aggregation pipeline. If the pipeline ends with a $out stage, the returned iterable will be a query of the collection that the aggregation was written to. Note that in this case the pipeline will be executed even if the iterable is never iterated.

Return

an iterable containing the result of the aggregation operation

Since

3.6

Parameters

clientSession

the client session with which to associate this operation

pipeline

the aggregate pipeline


abstract fun <TResult : Any> aggregate(    clientSession: ClientSession,     pipeline: List<Bson>,     resultClass: KClass<out TResult>): AggregateFlow<TResult>

Aggregates documents according to the specified aggregation pipeline. If the pipeline ends with a $out stage, the returned iterable will be a query of the collection that the aggregation was written to. Note that in this case the pipeline will be executed even if the iterable is never iterated.

Return

an iterable containing the result of the aggregation operation

Since

3.6

Parameters

clientSession

the client session with which to associate this operation

pipeline

the aggregate pipeline

resultClass

the class to decode each document into

the target document type of the iterable.