Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-12818

Highlight that _id should be removed before using $merge without _id in 'on' fields

      Description

      When designing the $merge stage we realized that using a set of 'on' fields other than _id will often result in the user accidentally trying to modify the _id of the target document. When the 'whenMatched' mode is "merge" (the default), the update generated by the $merge stage will include the _id from the document in the pipeline which is likely different than the one targeted by the 'on' fields. Further, because $project includes the _id by default, it might not be obvious to users whether the document going into $merge has an _id at all.

      cc asya

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              4 years, 41 weeks, 6 days ago