mongo js 遍历

db.getCollection('CPU').find({}).limit(100).sort({"time":-1}).forEach(
function(a){
    a["v"]=(new Date(a["time"]).toString());
    printjson((a["v"]))
    })
 

mongo 聚合

db.CPU.aggregate({
    $group:{_id:       
            
             {time:{ $mod: [ 4,1 ] }},
             "a":
             {$where: function() { return obj.credits - obj.debits < 0; }}
             
              
           }
    })
 
 
 db.CPU.aggregate({"$group":{"_id":{$ceil:{"$divide":["$time",60]}}}}).sum()
 

mongo 查询

db.getCollection('CPU').find({ $where: "this.time % 60 == 0" }).limit(360)
 

mongo Mapreduce

db.CPU.mapReduce(
    function() {emit(this._id,this.time);},
    function(key,values) {return Array.sum(values)},
       {
           query:{},
           
           }
)

Mongo 查询

相关文章:

  • 2022-01-08
  • 2021-09-07
  • 2021-08-23
  • 2022-03-05
  • 2022-12-23
  • 2022-02-12
  • 2021-06-04
  • 2022-02-06
猜你喜欢
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-02-03
  • 2021-10-20
相关资源
相似解决方案