您的位置:首页 > 数据库 > Mongodb

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

2015-07-03 14:32 741 查看
数据库内容大概如下:

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


> 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: