我的项目(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
这是一个虚假的问题?它看起来像接受的答案中的代码匹配您的原始问题。 –