2
更新子文檔說,我有一個集合allitems
其中每個文檔的形式與故障有關MongoDB
{_id: "1", items: [{number: 1, main: "how are you?", sub:[{id:1, item: "does it change with the day?", score: 0},{id:2, item:"some other question", score: 0}]}]}
如何更新一個子項的得分?
我已經試過
db.allitems.update({_id:"1"}, {$set:{'items.0.sub.0.score': 5}});
我得到這個錯誤:
error: {
"$err" : "Unsupported projection option: items.0.sub.0.score",
"code" : 13097
}
我該如何解決這個問題?
這是一個錯字...這不解決問題,錯誤似乎表明別的東西。 – algorithmicCoder 2013-03-02 04:20:23
沒關係....我有史以來最愚蠢的錯誤....我用「查找」而不是「更新」.....> = 2小時的我的生活可能會或可能不會被浪費:)謝謝您的幫助! – algorithmicCoder 2013-03-02 04:33:17
哈哈哈同樣的事情發生在我身上,你沒有注意到.find!特別是當你註釋掉東西 – 2015-01-13 01:20:30