toSequence

open fun toSequence(): <Error class: unknown class><Document>(source)

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

this.toList().asSequence()