I’m using the Tokio async runtime v2.0.1, and my DB version is 4.4. I have an update that executes, and the data successfully updates, but I’m returned an error that isn’t making sense. The error is:
let options = FindOneAndUpdateOptions::builder().upsert(false).build();
As I said, the update works, but the error comes back stating that the enable field is missing. The document in the db does have a lot of other fields, but I’m only updating one of them.
Hi Mark! Have you verified that the enable field is present in the document? The error you’re encountering does indicate that the data being returned from find_one_and_update does not contain the enable field. I recommend running this same operation in the shell or on a Collection<Document> and inspecting the data returned. You can use the clone_with_type method on your current collection to retrieve a Collection<Document>. You may need to adjust your filter to ensure you’re finding the correct document.
Alternatively, if you can’t guarantee that each document you’re retrieving from the collection will contain an enable field, you can adjust the corresponding field in the struct/enum you’re using to model your data to be an Option, which will allow for proper deserialization to None when the field is not present.
Please let us know if this helps or if you run into any further issues!