我存储在MongoDB中这样如何更新MongoDB的数组值
"Fiction" : [
{
"SNo": "1",
"authorName" : "Enid Blyton",
"bookName" : "Secret series",
"Amount" : 115
},
{
"SNo": "2",
"authorName" : "Enid Blyton",
"bookName" : "Mystery series",
"Amount" : 150
}
]
我想量更新来自115
到135
文档。
我试图更新像这样的值。
db.fiction.update({"Fiction.SNo":"1"},{$set:{"Fiction.Amount":135}})
但我得到一个错误。
的错误是
cannot use the part (Fiction of Fiction.Amount) to traverse the element
任何人都可以在这方面的帮助,我需要实现这个从蟒蛇工作。
db.fiction.update({ “斯诺”: “1”},{$组:{ “金额”:135}}) –