書き込みネストしたオブジェクトの更新次のドキュメントで、コメントの author を変更することを考えましょう。 {
"_id" : ObjectId("4b06c282edb87a281e09dad9"),
"content" : "this is a blog post.",
"comments" :
[
{
"author" : "Mike",
"comment" : "I think that blah blah blah...",
},
{
"author" : "John",
"comment" : "I disagree."
}
]
}
<?php位置指定演算子位置指定演算子 $ は、配列内のオブジェクトを更新するときに有用です。 たとえば上の例で、実際に変更したいコメントのインデックスがわからないけれども "John" を "Jim" に変更しなければならないという状況を考えてみましょう。 そんなときには $ が使えます。
<?php |