面试题答案
一键面试db.documents.updateMany(
{},
[
{
$set: {
arrayField: {
$map: {
input: "$arrayField",
in: {
$cond: [
{ $eq: ["$$this.name", "target"] },
{ name: "$$this.name", value: { $multiply: ["$$this.value", 2] } },
"$$this"
]
}
}
}
}
}
]
);