[SERVER-29119] Aggregation: Allow $out the ability to merge the output with the existing data Created: 10/May/17  Updated: 29/Jan/18  Resolved: 10/May/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Dmitry Ryabtsev Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-12280 allow $out to append to/merge with ex... Closed
Backwards Compatibility: Fully Compatible
Participants:
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"} }



 Comments   
Comment by Dmitry Ryabtsev [ 10/May/17 ]

Missed SERVER-12280 during my first search. So resolving this as Duplicate.

Generated at Thu Feb 08 04:19:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.