Skip to content

MongoDB driver for Kotlin (coroutines)opensavvy.ktmongo.coroutinesJvmMongoIterable

JvmMongoIterable

Implementation of MongoIterable based on MongoDB's FindFlow.

To access the inner iterable, see asKotlinMongoIterable.

To convert an existing MongoDB iterable into an instance of this class, see asKtMongo.

Functions

asFlow

open override fun asFlow(): Flow<Document>

Streams the results of this response into a Flow.

asKotlinMongoIterable

@LowLevelApi
fun asKotlinMongoIterable(): FindFlow<Document>

Converts a KtMongo MongoIterable into a MongoDB FindFlow.

asSequence

first

open suspend override fun first(): Document

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

firstOrNull

open suspend override fun firstOrNull(): Document?

Returns the first document found by this query, or null if none were found.

forEach

open suspend override fun forEach(action: suspend (Document) -> Unit)

Executes action for each document returned by this query.

toList

open suspend override fun toList(): List<Document>

Reads the entirety of this response into a List.

toSequence

toSet

open suspend fun toSet(): Set<Document>

Reads the entirety of this response into a Set.

toString

open override fun toString(): String