wither icon indicating copy to clipboard operation
wither copied to clipboard

[Docs] How does projection work in Rust?

Open wbrickner opened this issue 4 years ago • 1 comments

Hello,

wondering how this library can support document projection if not every field is an Option<T>?

For instance if I only want one field from matching documents, how is this possible in Wither, which returns my struct back to me?

It is supported under options, but I think deserialization will fail in this case, otherwise the application will have entered an unsound state.

Thank you.

wbrickner avatar Mar 18 '21 07:03 wbrickner

Hey Will, projection in Wither runs a bit counter to the purpose of Wither, which is to provide model-based interaction with your MongoDB data. You absolutely can use projections with the underlying driver, but you will get a raw BSON document back instead of a model instance.

thedodd avatar Mar 18 '21 12:03 thedodd