Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我在 mongodb 中有一个 json 文档
{ a:{b:c} }
现在,如果我想添加到嵌套的 json 中,我应该怎么做,这将使它看起来像:
{ a:{b:c, d:e} }
我已阅读update. 它记录了关于$inc, $rename, $set&的信息$unset。但我希望它添加现有的a. 就像$addToSet处理数组一样。
update
$inc
$rename
$set
$unset
a
$addToSet
您可以使用$set运算符:
collection.update({'a.b': 'c' }, {$set: {'a.d': 'e'}} )