【发布时间】:2019-05-02 23:07:28
【问题描述】:
我几乎没有 SQL 或 noSQL 方面的经验。
我需要更新每个文档,以便我的字段“Log*”位于新字段“Log”下
我从this StackOverflow 那里找到了一些帮助,但我仍然想知道如何移动数据。
非常感谢
原始文件
// collection: Services
{
"_id" : ObjectId("5ccb4f99f4953d4894acbe79"),
"Name" : "WebAPI",
"LogPath" : "Product\\APIService\\",
"LogTypeList" : [
{
"Name" : "ApiComCounter",
"FileName" : "ApiComCounter.log"
},
{
"Name" : "ApiService",
"FileName" : "ApiService.log"
}
]
}
最终文件
// collection: Services
{
"_id" : ObjectId("5ccb6fa2ae8f8a5d7037a5dd"),
"Name" : "InvoicingService",
"Log" : {
"LogPath" : "Product\\APIService\\",
"LogTypeList" : [
{
"Name" : "ApiComCounter",
"FileName" : "ApiComCounter.log"
},
{
"Name" : "ApiService",
"FileName" : "ApiService.log"
}
]
}
}
【问题讨论】: