zoukankan      html  css  js  c++  java
  • mongodb操作技巧

    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

  • 相关阅读:
    HUST-1350 Trie
    hihocoder-第六十一周 Combination Lock
    hihocoder-1196 : 高斯消元·二
    hihocoder-1195 : 高斯消元·一
    SPOJ
    HDU-5074
    UVALive
    POJ-2195
    UVALive
    POJ-1556
  • 原文地址:https://www.cnblogs.com/cuishuai/p/8617716.html
Copyright © 2011-2022 走看看