MongoIterable

open class MongoIterable<T>(delegate: MongoIterable<T>)

The MongoIterable is the results from an operation, such as a query.

Parameters

T

The type that this iterable will decode documents to.

Inheritors

Constructors

Link copied to clipboard
constructor(delegate: MongoIterable<T>)

Functions

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

Sets the number of documents to return per batch.

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 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 <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 <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.