我有以下集合的mongodb
management_model:PRIMARY> db.info.find()
{
"_id" : ObjectId("58c78f1fbda0608671cd06c6"),
"name" : "somename",
"age" : 25
}
{
"_id" : ObjectId("58c791b9219b7932ab093f20"),
"name" : "Alice",
"age" : 26
}
{
"_id" : ObjectId("58c79351a04681dda3314d6f"),
"name" : "Bob",
"age" : 36,
"additional" : [
{
"old" : "No"
}
]
}
我想更新" old" :"是"使用update()方法但是当我尝试以下方式时,似乎没有任何工作。
1
management_model:PRIMARY> db.info.update( {_id: "58c79351a04681dda3314d6f"}, {$set: {"additional.0.old": "yes"} } )
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 })
management_model:PRIMARY> db.info.update( {_id: "58c79351a04681dda3314d6f"}, {$set: {"additional.old": "yes"} } )
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 })
以上所有查询均表示未找到匹配项。我错过了什么吗?
-Prashanth