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

POC: Merging style of $out

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Query 2019-03-25, Query 2019-04-08, Query 2019-04-22

    Description

      In PM-1021 we are still flushing out the syntax of how to do so, but we're proposing adding a mode for $out or a $out-like stage which will take documents from the pipeline and merge them with documents in the collection, like {$mergeObjects: [<existing>, <new>]}. Fields present only in the existing document remain unchanged. Fields present only in the computed document are added to the document. Fields present in both documents will take the value from the new document. This applies to top-level fields, sub-objects are not merged.

      In this POC, we should add a new flag to $out (I propose just using a new mode "mergeDocuments" for now, since that's at least one of the options on the table) and add the ability for $out to do this. To achieve this, we just need a new subclass of $out which calls a new method on the process interface. This will look very similar to this call, but instead of just directly passing the objects from the batch, it should wrap each one in a {$set: <object>} to make it so the update has the semantics we want.

      Attachments

        Activity

          People

            anton.korshunov@mongodb.com Anton Korshunov
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: