数据库内容大概如下:
{ _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
mongodb 更新数组出现can't append to array using string field name
时间: 2024-09-30 03:34:37