MongoIterable¶
interface MongoIterable<Document : Any>
Streaming-ready iterable client to read data from the database.
Inheritors¶
Functions¶
asSequence¶
open fun asSequence(): Sequence<Document>
Deprecated (with error)¶
Kotlin Sequences are not capable of closing a resource after they are done. Using sequences with a MongoIterable will create memory leaks. Instead, use toList, forEach, asStream (Java only) or the coroutines driver's asFlow
Replace with
first¶
Returns the first document found by this query, or throws an exception.
See also
Throws
NoSuchElementException-
If this query returned no results.
firstOrNull¶
abstract fun firstOrNull(): Document?
Returns the first document found by this query, or null if none were found.
See also
forEach¶
Executes action for each document returned by this query.
This method streams all returned elements into the action function. The entire response is not loaded at once into memory.
toList¶
Reads the entirety of this response into a List.
Since lists are in-memory, this will load the entirety of the results of this query into memory.
See also
toSequence¶
open fun toSequence(): Sequence<Document>
Deprecated (with error)¶
Kotlin Sequences are not capable of closing a resource after they are done. Using sequences with a MongoIterable will create memory leaks. Instead, use toList, forEach, asStream (Java only) or the coroutines driver's asFlow
Replace with
toSet¶
Reads the entirety of this response into a Set.
Since sets are in-memory, this will load the entirety of the results of this query into memory.
See also