MongoAggregationPipeline

A multi-stage aggregation pipeline that transforms documents from a MongoDB collection.

Pipelines are immutable. Each stage method returns a new pipeline with the stage appended.

To obtain a pipeline, use MongoCollection.aggregate.

Example

class User(
val name: String,
val age: Int,
)

users.aggregate()
.match { User::age gt 18 }
.sort { ascending(User::name) }
.toList()

External resources

Properties

Link copied to clipboard

Functions

Link copied to clipboard

Streams the results into a Flow.

Link copied to clipboard

Access the data of this pipeline as a MongoIterable.

Link copied to clipboard
abstract override fun <Out : Any> countTo(field: KProperty1<Out, Number>): MongoAggregationPipeline<Out>
abstract override fun <Out : Any> countTo(field: Field<Out, Number>): MongoAggregationPipeline<Out>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns the first document found by this query, or throws an exception.

Link copied to clipboard

Returns the first document found by this query, or returns null.

Link copied to clipboard
inline suspend fun <Document : Any> MongoAggregationPipeline<Document>.forEach(noinline action: suspend (Document) -> Unit)

Executes action for each document returned by this query.

Link copied to clipboard
abstract override fun <Out : Any> group(block: GroupStageOperators<Document, Out>.() -> Unit): MongoAggregationPipeline<Out>
Link copied to clipboard
abstract override fun limit(amount: Int): MongoAggregationPipeline<Document>
abstract override fun limit(amount: Long): MongoAggregationPipeline<Document>
Link copied to clipboard
Link copied to clipboard
abstract override fun match(filter: FilterQuery<Document>.() -> Unit): MongoAggregationPipeline<Document>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract override fun sample(size: Int): MongoAggregationPipeline<Document>
Link copied to clipboard
abstract override fun set(block: SetStageOperators<Document>.() -> Unit): MongoAggregationPipeline<Document>
Link copied to clipboard
abstract override fun skip(amount: Int): MongoAggregationPipeline<Document>
abstract override fun skip(amount: Long): MongoAggregationPipeline<Document>
Link copied to clipboard
abstract override fun sort(block: SortOptionDsl<Document>.() -> Unit): MongoAggregationPipeline<Document>
Link copied to clipboard

Reads the entirety of this iterable into a List.

Link copied to clipboard

Reads the entirety of this iterable into a Set.

Link copied to clipboard
abstract override fun toString(): String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun writeTo(writer: BsonValueWriter)