-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
Query Execution
my understanding is that updateOne returns a modifiedCount field indicating if a document has actually been modified (i.e. can be used to distinguish if a field has actually changed vs a redundant action of attempting to update a existing field to it's original value).
findOneAndUpdate doesn't appear to communicate that same information such that it is impossible to distinguish the case where an update operation has no overall effect on a document because no field has actually changed from it's original value.
i realize that the existing return value needs to stay consistent for backwards compatibility, but maybe introduce a different method (e.g. updateAndFetch) or a flag to this method (e.g. includeInfo) which will allow a result looking something like:
{
document: <either original or new document here depending on flag>,
modifiedCount: <counter indicating whether an actual modification has occurred>
}
- is duplicated by
-
SERVER-66740 findAndModify.lastErrorObject.updatedExisting always true after and update
- Closed
- is related to
-
SERVER-42741 getting back both _id of modified documents and writeResult information
- Backlog
- related to
-
SERVER-66740 findAndModify.lastErrorObject.updatedExisting always true after and update
- Closed