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

Aggregation: Allow $out the ability to merge the output with the existing data

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Fully Compatible

      Unlike with mapReduce, there is no way to specify additional options for $out. If the target collection already exists, it will simply get overwritten.

      This is inconvenient and does not allow users to easily write from one collection directly into another preserving the existing data.

      Note that in SQL writing from one collection into another is as simple as:

      INSERT INTO table2
      SELECT * FROM table1
      WHERE condition;
      

      At this moment we do not provide the same simplicity of usage.

      It would be great if we could provide options to alter the behaviour of the $out operator. For example:

      { $out: { $merge: "collection" } }
      //or
      { $out: { $merge: "collection", $keep: "oldest" } }
      //or
      { $out: { $merge: "collection", $keep: "newest"} }
      //or
      { $out: { $replace: "collection"} }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            dmitry.ryabtsev@mongodb.com Dmitry Ryabtsev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: