notes
notes copied to clipboard
MongoDB copy field value to another field
情景
某些时候我们需要将某个字段的值拷贝给同一张表下面的其他字段。
代码
db.my_collection.aggregate(
[
{ "$addFields": {
"name": { "$concat": [ "$firstName", " ", "$lastName" ] }
}},
{ "$out": "my_collection" }
]
);