1、添加字段或更新值

db.getCollection('test').updateMany( {}, { $set:{ 'createTime':'2017-06-29 08:08', 'updateTime':'2017-06-29 08:08 } } );


2、更新字段类型和值
db.getCollection('coinreviews').find({}).forEach(
    function(x){
        x.groupSize = new NumberInt(x.groupSize);// 将字符串转化为数字
        x.lotterySize = new NumberInt(x.lotterySize);
        db.coinreviews.save(x);//保存数据
});
 
3、查询阻塞,数据库压力变大,需要kill掉耗时比较长的查询
 

db.currentOp({"ns" : "saturn.activitylotteryticketlogs"}).inprog.forEach(function(x){

 db.killOp(x.opid)

})

 

https://docs.mongodb.com/manual/reference/method/db.currentOp/#db.currentOp

相关文章:

  • 2022-01-13
  • 2021-06-21
  • 2021-06-12
  • 2021-04-29
  • 2022-02-08
  • 2021-11-02
  • 2022-02-23
  • 2021-09-01
猜你喜欢
  • 2021-12-04
  • 2021-11-28
  • 2021-11-09
  • 2021-06-11
  • 2021-10-30
  • 2021-12-25
  • 2022-01-01
相关资源
相似解决方案