mongodb 更新数组出现can't append to array using string field name

数据库内容大概如下:

{
_id:,
"hero_list" : {
"" : {
"stars" : ,
"_id" : ,
"equip" : [
[ ],
[ ],
[ ],
{
"item_id" : ,
"lv" : ,
"uuid" : "4a727ee1-e7b0-4265-b004-e2b75890378a",
"amount" :
},
[ ],
[ ]
],
"lv" : ,
"exp" : ,
"quality" :
}
}
}

> db.hero.update({_id:1},{$set:{"hero_list.15521.equip.4.lv":1}})
can't append to array using string field name [lv]

看了半天,原来是自己眼花,数组下标数错了

db.hero.update({_id:1},{$set:{"hero_list.15521.equip.3.lv":1}})

OK

上一篇:框架篇:Spring+SpringMVC+Mybatis整合开发


下一篇:Spring+SpringMVC+MyBatis整合基础篇(二)牛刀小试