我的項目(Projects
)用一記project
它有一個數組equipInfo
集合,可以說我想更新索引1的陣列數量:蒙戈更新領域的指數
"techInfo" : {
"equipInfo" : [
{
"item" : {
"$ref" : "equipment",
"$id" : ObjectId("581a20cb4abab607fd17f07d")
},
"quantity" : "22800",
"type" : "module"
},
{
"item" : {
"$ref" : "equipment",
"$id" : ObjectId("581a20cb4abab607fd17f07e")
},
"quantity" : "1666", <===== UPDATE THIS!!!!!!
"type" : "inverter"
}
]
}
所以,我想:
Projects.update(
{_id: projectId},
{$set: {"techInfo.equipInfo.1.quantity": 1000000}
);
但這不起作用,我使用Meteor.js順便說一句
使用0 {$設置:{「techInfo.equipInfo.1.quantity」:1000000}檢查我的答案 –
你在客戶端或服務器上嘗試過嗎?你有錯誤嗎?與你期望的結果不同?正如其他人所說,你的聲明甚至沒有編譯(語法錯誤)。 – MasterAM
這是一個虛假的問題?它看起來像接受的答案中的代碼匹配您的原始問題。 –