|
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.
|