AggregationPipeline

Fluent interface for building MongoDB aggregation pipelines.

Each operation returns a new pipeline instance (immutable pattern).

Inheritors

Functions

Link copied to clipboard
abstract fun addFields(block: AddFieldsBuilder<T>.() -> Unit): AggregationPipeline<T>

Performs add fields operations

Link copied to clipboard
abstract fun count(): Long

Execute pipeline and return count of matching documents.

Link copied to clipboard
abstract fun customStage(stageName: String, block: CustomStageBuilder.() -> Unit): AggregationPipeline<T>

For building custom stages

Link copied to clipboard
abstract fun <R : Any> facet(resultType: KClass<R>, block: FacetBuilder<T>.() -> Unit): AggregationPipeline<R>
Link copied to clipboard
abstract fun firstOrNull(): T?

Execute pipeline and return first result or null.

Link copied to clipboard
abstract fun group(block: GroupBuilder<T>.() -> Unit): AggregationPipeline<Document>

abstract fun <R : Any> group(resultType: KClass<R>, block: GroupBuilder<T>.() -> Unit): AggregationPipeline<R>

Perform grouping operations in pipeline

Link copied to clipboard
abstract fun <R : Any> into(resultType: KClass<R>): AggregationPipeline<R>
Link copied to clipboard
abstract fun limit(count: Int): AggregationPipeline<T>

Limit to N documents ($limit stage).

Link copied to clipboard
abstract fun match(block: MatchBuilder<T>.() -> Unit): AggregationPipeline<T>

Filter documents ($match stage).

Link copied to clipboard
abstract fun paginate(page: Int, pageSize: Int): AggregationPipeline<PagedResult<T>>

Paginate result of previous stages output

Link copied to clipboard
abstract fun skip(count: Int): AggregationPipeline<T>

Skip N documents ($skip stage).

Link copied to clipboard
abstract fun sort(block: SortBuilder<T>.() -> Unit): AggregationPipeline<T>

Sort documents ($sort stage).

Link copied to clipboard
abstract fun toAggregation(): Aggregation

Get raw Spring Data Aggregation for debugging.

Link copied to clipboard
abstract fun toJson(): String

Get pipeline as JSON string for debugging.

Link copied to clipboard
abstract fun toList(): List<T>

Execute pipeline and return all results.