-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Fully Compatible
-
(copied to CRM)
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"} }
- duplicates
-
SERVER-12280 allow $out to append to/merge with existing collection instead of replacing it
- Closed