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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Case:

      Description

      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"} }
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: