mongoDB 更新嵌套数组中的某个字段
2023-02-26 19:06:14
db.getCollection(collection).updateMany({
    $and:[
        {tags: {$exists: true }},
        {'tags.name': {$eq: "name"}}
    ]
}, {
    $set: {
        "tags.$[elem].value": "name"
    }  
}, {
    arrayFilters: [
        {"elem.name": {$eq: "name"}}
    ]
})