zoukankan      html  css  js  c++  java
  • mongo 常用操作

    删除字段

    db.matchconfs.update({},{$unset:{used:""}},false,true)

    添加字段

    db.matchconfs.update({},{$set:{used:0}},false,true)

    更加某个字段更新另一个字段

    db.masterscorenews.update({uid:1111},[{ $set:{ bak:"$age" } }])

     查询

    db.quweimodels.find({ uri:{$regex://identity_number//} }, {err:1, uri:1, "reqArgs.body":1,body:1})

    // 新增字段,idtype, 内容为$id[:12]
    db.matchconfs.aggregate(
       [
    
         {
            $set:
            {
              idtype: { $substr: [ "$id", 0, 12 ] },
            }
        },
        {
            $out:"matchconfs"
        }
        ]
    );
    // 选出不同的idtype
    db.matchconfs.aggregate([
    {
        $facet:{
            "selectAB":[
                {$match:{type:{$gte:3}}},
                {$group:{_id:{$substr:["$id",0,12]}}},
            ],
            
            "selectTaotai":[
                {$match:{type:1}},
                {$group:{_id: {$substr:["$promote_match",0,12]}  }},
            ]
        }
    },
    {
        $unwind:
          {
            path: "$selectAB",// 所有复式赛类型
          }
    },
    {
        $project:{
            _id:"$selectAB._id",
            isBind:{
               $in:["$selectAB._id","$selectTaotai._id"]
            }
        }
    },
    {
        $out:"fushitypes"
    }
    ])
  • 相关阅读:
    jstat命令-帮助优化java性能
    使用nginx搭建简单文件服务器
    JVM初探
    fastDFS shiro权限校验 redis FreeMark页面静态化
    spring AOP
    Java多线程并发
    js插件之Ocupload
    Jquery总结
    shell
    Linux(二)
  • 原文地址:https://www.cnblogs.com/dzqdzq/p/12021343.html
Copyright © 2011-2022 走看看