Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior of evaluate when no results are available #384

Open
CLOVIS-AI opened this issue Nov 17, 2022 · 4 comments
Open

Behavior of evaluate when no results are available #384

CLOVIS-AI opened this issue Nov 17, 2022 · 4 comments
Labels

Comments

@CLOVIS-AI
Copy link

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?

@zigzago
Copy link
Member

zigzago commented Nov 27, 2022

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

@CLOVIS-AI
Copy link
Author

Is it possible to make it clear in evaluate's documentation?

@zigzago
Copy link
Member

zigzago commented Nov 27, 2022

@CLOVIS-AI
Copy link
Author

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

@zigzago zigzago added the doc label Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants