[英]How to update the value of the field in mongodb?
我在mongodb中有如下文檔:
{
"_id":"563f480fb5c2187503eefc1a",
"ownerBy":"56335521f2f4a3150349d78d",
"data": {
"username1":"76561198060520554",
"username2":"76561198060520554",
"username3":"76561198060520554",
"username4":"76561198060520554",
"username5":"76561198060520554"
},
"__v":0
}
客戶端希望將username1
的值更新為以下newValue
:
{ newValue: 'as76561198060520554',
id: 'username1',
column: 'selectable'
}
如何找到字段_id
並將其替換為newValue
?
鑒於我們掌握的信息很少,這可能就是您要找的!
收藏將是您收藏的名稱!
Collection.update({
"_id":"563f480fb5c2187503eefc1a"
},
{$rename: {"_id" : "newValue"}},
{$set: {
newValue: 'as76561198060520554',
id: 'username1',
column: 'selectable'
}},
{"upsert": true});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.