MongoDb更改嵌入文档中的值

MongoDb更改嵌入文档中的值,mongodb,Mongodb,我想将值“y”更改为“no”,如何更改? 希望你能回答 感谢在更新中使用运算符和运算符在数组中设置元素,而无需明确指定元素在数组中的位置,即 { "_id" : ObjectId("54fd4ddaa037ba481d794f5e"), "question" : "let me go?", "choices" : [ { "text" : "yes", "_id" : ObjectId("54fd4ddaa037ba481d794f60"),

我想将值“y”更改为“no”,如何更改? 希望你能回答 感谢在更新中使用运算符和运算符在数组中设置元素,而无需明确指定元素在数组中的位置,即

{ 
"_id" : ObjectId("54fd4ddaa037ba481d794f5e"), 
"question" : "let me go?", 
"choices" : [ 
    { 
        "text" : "yes", 
        "_id" : ObjectId("54fd4ddaa037ba481d794f60"), 
        "votes" : [ ] 
    }, { 
        "text" : "y", 
        "_id" : ObjectId("54fd4ddaa037ba481d794f5f"), 
        "votes" : [ ] 
    } 
], 
"__v" : 0 
}

使用运算符设置数组中的元素,即
db.collection.update({{u id:ObjectId(“54fd4ddaa037ba481d794f5e”)},{$set:{“choices.1.text”:“no”})非常感谢,它成功了!
db.collection.update(
    { "question": "let me go?", "choices.text": "y" }, 
    { $set: { "choices.$.text": "no" } }
);