Litote / kmongo

[deprecated] KMongo - a Kotlin toolkit for Mongo
https://litote.org/kmongo/
Apache License 2.0
781 stars 75 forks source link

Using `projection` in with client session using coroutines #400

Closed MMauro94 closed 1 year ago

MMauro94 commented 1 year ago

Hello! I think a projection(ClientSession, ...) extension function is missing from the coroutine module. I see that they are present in the kmongo-core (here), but I cannot find them anywhere in the kmongo-coroutine-core module.

For the time being I've used .find(ClientSession, ...), but I'd like to be able to use projection for performance concerns.

Is there any reason why they are not present or they were simply forgotten? Is there a different/better way to use projections with sessions on the coroutine module?

zigzago commented 1 year ago

Only a maximum of three fields are supported for this extension. That's why it was not copied for the coroutine module. The recommended way is to use a custom dedicated class:

Look at the doc https://litote.org/kmongo/extensions-overview/#projection

HTH