我收集了foo
份文件,包括:
{site_id: 'xxx', title: {ru: 'a', en: 'b'}, content: {ru: 'a', en: 'b'}}
{site_id: 'xxx', title: {ru: 'c', de: 'd'}, content: {ru: 'c', de: 'd'}}
我需要更新多个字段,这些字段可以存在也可以不存在:
db.foo.update(
{ site_id: 'xxx'},
{ $set: {'title.de': '', 'content.de': ''}},
{multi: true}
)
但我需要像$set
这样的东西,如果它存在,它不会覆盖值.