我需要将最后一个元素中的项目文本修改为“这里是3”。
该收藏集被命名为“门票”。
{
"_id": "5d7809b728468a06de12982b",
"status": "New",
"actionList": [
{
"actionName": "Show To Customer",
"createTime": "2019-09-10T20:39:49.479Z",
"text": "Here is 1"
},
{
"actionName": "Commented",
"visibilityLevel": 10,
"text": "Here is 2"
},
{
"actionName": "Commented",
"visibilityLevel": 10,
"text": "Here is 4"
}
]
}
基于其他方法,此方法无效;
update( {_id:ObjectId('5d852656b1348d6c9a043872'), actionList.0 : "Here is 4"}, {$set: {"actionList.$" : "Here is 3"}})
答案 0 :(得分:0)
找到了另一个解决方案:
update( {"_id":ObjectId("5d7809b728468a06de12982b")}, {$set:{"actionList.2.text" : "Here is 3"}})