Question

Is there a way to get the changes to a document upon saving it with the official MongoDB .NET driver. I am only looking for the delta so that I can Audit the changes. Thanks!

Was it helpful?

Solution

The server doesn't provide any deltas back to the client, so any such thing would have to be done client side. The C# driver doesn't have any such functionality either.

You would have to keep a copy of the original document before you started changing it and then do the deltas yourself.

You could also consider using FindAndModify, which can return the original document, thus relieving you of having to keep an original copy of the document.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top