我拼命寻找一个非常简单问题的解决方案。我使用 NINJA 和 Robomongo 作为环境。
我想将一个集合添加到现有的集合中,所有这些都在同一个 FOR 循环中:
现存的:
{
"_id" : ObjectId("54608d9f35121b0e18aa01b2"),
"level1" : {
"item1" : 200.55,
"item2" : "001",
"item3" : 708874,
}
}
想要得到:
{
"_id" : ObjectId("54608d9f35121b0e18aa01b2"),
"level1" : {
"item1" : 200.55,
"item2" : "001",
"item3" : 708874,
"level2" : {
"item4" : 200.55,
"item5" : "001",
"item6" : 708874,
}
}
}
我尝试使用 $set (unset=True)、$addToSet 等进行 UPDATE。问题似乎不是数组。
感谢帮助