MongoDB 字段重命名

MongoDB About 302 words

$rename

可用于修改字段名称。

{$rename: { <field1>: <newName1>, <field2>: <newName2>, ... } }

重命名

_id1的记录中的account_id字段修改为user_id

db.getCollection('user').update({_id:1},{$rename:{"account_id":"user_id"}})

批量修改

db.getCollection('user').updateMany({},{$rename:{"account_id":"user_id"}})
Views: 2,775 · Posted: 2020-04-09

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh