In MongoDB how do you use $set to update a nested value/embedded document?

后端 未结 2 2024
你的背包
你的背包 2020-12-09 15:08

In MongoDB how do you use $set to update a nested value?

For example, consider a collection people with the following

2条回答
  •  轮回少年
    2020-12-09 15:30

    In addition to Niels' answer, also do verify the "type" of the nested value. In my case, it was a "string" formed from json. Though this might be unlikely, but do ensure that the value has the right type.

提交回复
热议问题