kmongo
kmongo copied to clipboard
Behavior of `evaluate` when no results are available
What does evaluate do when no results are found?
Ideally, I'd like it to call the lambda with an empty sequence:
myCollection.find(…).evaluate {
println(isEmpty()) // prints 'true'
}
In case this is the current behavior, would it be possible to add a sentence to make it clear in evaluate's documentation?
Kotlin sequences (https://kotlinlang.org/docs/sequences.html) do not have isEmpty() method but you can write
col.find().evaluate {
println(count() == 0) // prints 'true'
}
HTH
Is it possible to make it clear in evaluate's documentation?
What would you like to add to the current doc? https://litote.org/kmongo/dokka/kmongo/org.litote.kmongo/com.mongodb.client.-mongo-iterable/evaluate.html
“Evaluates the current MongoIterable given the expression of Sequences, including when it is empty.” or similar.
At least this way it's clear that it's an intended behavior and it won't go away in the future.