AggregateIterable

class AggregateIterable<T : Any>(wrapped: AggregateIterable<T>) : MongoIterable<T>

Iterable like implementation for aggregate operations.

Parameters

T

The type of the result.

See also

Constructors

Link copied to clipboard
constructor(wrapped: AggregateIterable<T>)

Functions

Link copied to clipboard
fun allowDiskUse(allowDiskUse: Boolean?): AggregateIterable<T>

Enables writing to temporary files. A null value indicates that it's unspecified.

Link copied to clipboard
open override fun batchSize(batchSize: Int): AggregateIterable<T>

Sets the number of documents to return per batch.

Link copied to clipboard
fun bypassDocumentValidation(bypassDocumentValidation: Boolean?): AggregateIterable<T>

Sets the bypass document level validation flag.

Link copied to clipboard
fun collation(collation: Collation?): AggregateIterable<T>

Sets the collation options

Link copied to clipboard
fun comment(comment: BsonValue?): AggregateIterable<T>

Sets the comment for this operation. A null value means no comment is set.

Link copied to clipboard
open fun cursor(): MongoCursor<T>

Returns a cursor used for iterating over elements of type `T. The cursor is primarily used for change streams.

Link copied to clipboard
fun explain(verbosity: ExplainVerbosity? = null): Document
inline fun <R : Any> explain(verbosity: ExplainVerbosity? = null): R
fun <R : Any> explain(resultClass: Class<R>, verbosity: ExplainVerbosity? = null): R

Explain the execution plan for this operation with the given verbosity level

Link copied to clipboard
fun first(): T
Link copied to clipboard
fun firstOrNull(): T?
Link copied to clipboard
fun forEach(action: (T) -> Unit)

Performs the given action on each element and safely closes the cursor.

Link copied to clipboard
fun hint(hint: Bson?): AggregateIterable<T>

Sets the hint for which index to use. A null value means no hint is set.

Link copied to clipboard

Sets the hint to apply.

Link copied to clipboard
fun let(variables: Bson?): AggregateIterable<T>

Add top-level variables to the aggregation.

Link copied to clipboard
fun <R> map(transform: (T) -> R): MongoIterable<R>

Maps this iterable from the source document type to the target document type.

Link copied to clipboard
fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): AggregateIterable<T>

The maximum amount of time for the server to wait on new documents to satisfy a $changeStream aggregation.

Link copied to clipboard
fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): AggregateIterable<T>

Sets the maximum execution time on the server for this operation.

Link copied to clipboard
@Alpha(value = [Reason.CLIENT])
fun timeoutMode(timeoutMode: TimeoutMode): AggregateIterable<T>

Sets the timeoutMode for the cursor.

Link copied to clipboard

Aggregates documents according to the specified aggregation pipeline, which must end with a $out or $merge stage.

fun <C : MutableCollection<in T>> toCollection(destination: C): C

Appends all elements to the given destination collection.

Link copied to clipboard
fun toList(): List<T>
Link copied to clipboard
fun <R> use(consumer: (Sequence<T>) -> R): R

Creates a new cursor and treats it as a Sequence, invokes the given consumer function and closes the cursor down correctly whether an exception is thrown or not.