Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-28145

add ability to obtain modified flag from findOneAndUpdate result

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 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>
      }
      

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            tony-kerz tony kerz
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: