将现有的外部文档移至内部文档
给定与以下文档相似的文档集合,
{
"description": "janeetjack",
"name": "Pocog bistro janeetjack"
}
该文档名称是一个唯一字段
,我如何更新所有现有文档并添加其他字段,从而看起来像这样
{
"userDetails":{
"description": "janeetjack",
"name": "Pocog bistro janeetjack"
},
"userLikes":{
"likes": "food",
"plays": "ball"
},
}
Given a collection of documents similar to the following document
{
"description": "janeetjack",
"name": "Pocog bistro janeetjack"
}
where name is a unique field
How do I update all existing documents and add additional fields so it looks like this
{
"userDetails":{
"description": "janeetjack",
"name": "Pocog bistro janeetjack"
},
"userLikes":{
"likes": "food",
"plays": "ball"
},
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要运行
set
和unset
在所有文档上使用updatemany
游乐场
You need to run
set
andunset
on all docs withupdateMany
Playground