In some database engines such as Oracle, we can get access to current fields to value even the previous or next one using lead and lag.
Is it possible to get access to the current value of a document before the update? I know I can query it but it has some performance costs.
It might be possible within a Transaction. Might be worth looking into that.
Or consider ways to mitigate those performance costs, and query it.
I think what you are looking for is findAndModify() function.
It does two operations in one go. First it finds the document that matches the query and then updates it.
Yes, this function modifies and returns a single document. By default, the returned document does not include the modifications made on the update. To return the document with the modifications made on the update, use the
Hope it helps!
If you still have any query, please feel free to get back to us.
Curriculum Support Engineer