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

XMLWordPrintableJSON

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

      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
            Reporter:
            Dmitry Ryabtsev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: