[CSHARP-3520] FindOneAndUpdateAsync does not work correctly Created: 01/Apr/21  Updated: 27/Oct/23  Resolved: 06/Apr/21

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Anıl Dursun ŞENEL Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

FindOneAndUpadete methods does not returns actual updated objects.

Steps

-FinfOneAndUpdateAsync  calls from all overload.

-The old object returns.

-When checks foır db the object is the updated object



 Comments   
Comment by Robert Stam [ 06/Apr/21 ]

FindOneAndUpdate can return either the document as it was before the update or after the update. 

The default action is to return the document as it was before the update.

If you wish you can specify in the options that you want FindOneAndUpdate to return the document as it is after the update:

var options = new FindOneAndUpdateOptions<TDocument> { ReturnDocument = ReturnDocument.After };
var result = collection.FindOneAndUpdate(filter, update, options); 

Generated at Wed Feb 07 21:45:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.