MENU

mongodb修改字段名字

April 15, 2022 • 已被 635 位童鞋围观过 • 代码分享,Mongo

以下仅仅为自己用过的,做一下标记

db.IP_Base.updateMany(
{"Cache.cache_time" : {$gt: 0}},
   [
       { $set: { cache_time: "$Cache.is_cache_time" } },
        { $unset: [ "Cache" ] }
   ]
)


db.IP_Base.updateMany(
      {  },
      { $set: { "cache_time:" : NumberInt(1641789918)} }
   );


db.IP_Base.updateMany(
{ },
   [

        { $unset: [ "cache_time" ] }
   ]
)

db.ICP.updateMany(
{},
   [
       { $set: { "cache_time":"$cache" } },
        { $unset: [ "cache"] }
   ]
)




Last Modified: September 28, 2023