I've got a good deal of code written against mongo using the Rust crate but have run into a bit of a problem.
I want to use update_one to do insert-or-update. The problem is that if I give the fn a serde-generated document using bson::to_bson as usual, the following error results:
"update document must have first key starting with '$"
Digging, it turns out that this functionality requires passing an update statement instead of a document. This can be done with the doc! macro easily enough, but that would be really ugly in our code base.
Looking thru the docs, I can't see a way to go from a serde Deserializable to an update statement.
I don't get why the size of the struct would matter? A big type can be serialized just like a small type. This snippet never needs to do anything that would depend on the size after constructing the instance (which you need to do anyway).