梗概
- 将传入的collection写入到另一个collection中
语法
实例
$merge: {
into: "myOutput",
on: "_id",
whenMatched: "replace",
whenNotMatched: "insert"
}- 写入到myOutput这个collection中
- 判断是否document相同的标准为“
_id”这个field- 如果目标collection没有,就插入
- 如果目标ccollection有,就覆盖
$merge: {
into: "myOutput",
on: "_id",
whenMatched: "replace",
whenNotMatched: "insert"
}_id”这个field