我有以下文件:
{
"_id":"000001"
"publicId":"0001"
"name":John"
}
现在我想在每个publicId之前联合“M”。我这样查询:
db.names.aggregate(
[
{ $project: { publicId: { $concat: [ "M", "$publicId" ] } }},
{$out:"names"}
]
)
我遇到的问题是我丢失了名称属性:
{
"_id":"000001"
"publicId":"M0001"
}
我该如何防止这种情况?