Details
-
New Feature
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
Fully Compatible
-
Query 2019-04-22, Query 2019-05-06
Description
This stage replaces the new modes of $out.
The syntax is:
{$merge: {
|
into: "collection name" OR {db: "db name", coll: "collection name"},
|
on: <fields used to uniquely identify a document>,
|
let: <optional, variables to be in scope for pipeline below>,
|
whenMatched: "replace|keepExisting|fail|merge|pipeline",
|
whenNotMatched: "insert|discard|fail"
|
}}
|
This ticket tracks support for the combination of modes already supported by $out:
mode "insertDocuments":
{$merge: {
|
into: "x",
|
on: "x_id"
|
whenMatched: "fail",
|
whenNotMatched: "insert"
|
}}
|
mode "replaceDocuments":
{$merge: {
|
into: "x",
|
on: "x_id"
|
whenMatched: "replaceWithNew",
|
whenNotMatched: "insert"
|
}}
|
Support for other modes is tracked in their own tickets.
Attachments
Issue Links
- is depended on by
-
SERVER-40430 Add $merge support for whenMatched: 'merge'
-
- Closed
-
-
SERVER-40431 Add $merge support for whenMatched: pipeline
-
- Closed
-
-
SERVER-40438 Add $merge support for whenNotMatched: "fail"
-
- Closed
-
-
SERVER-40439 Add $merge support for whenNotMatched: "discard"
-
- Closed
-
-
SERVER-40440 Add $merge support for whenMatched: 'keepExisting'
-
- Closed
-
-
SERVER-41175 Ensure $merge is not allowed in $lookup sub-pipelines
-
- Closed
-
- is documented by
-
DOCS-12675 Docs for SERVER-40429: Add $merge stage to write output to existing collection
-
- Closed
-
- is related to
-
SERVER-2517 Allow mapReduce to create full documents
-
- Closed
-