Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1820

'fields' option is not working as expected in findAndModify

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.3.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      OS:
      node.js / npm versions:
      Additional info:
    • Iteration Hippocamp
    • Not Needed
    • Developer Tools

      Try running something like
      ```
      db.foo.findAndModify({
      query:

      { _id: 1 }

      ,
      fields:

      { foo: 0 }

      ,
      update: { $set:

      { foo: 4 }

      },
      });
      ```
      You'll see that foo is returned in the result of this query even if it is excluded via `fields`.

      See Slack channel thread here:
      https://mongodb.slack.com/archives/C0V2M1UH3/p1719607938376519
      Created with Jira Integration+ for gaurab.aryal (gaurab.aryal@mongodb.com)

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            gaurab.aryal@mongodb.com Gaurab Aryal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: