mongo表 每天增量统计

 

querytime 类型不统一    有的是NumberLong类型 有的是string类型

 

var dt='2018-07-07';
var timestamp = Date.parse(dt+' 00:00') / 1000;
var arr = ['ncallrecords','nsms','ncontacts','user_action','lbs','mobile'];
for (var i=0;i<arr.length;i++){
if (arr[i]=='ncallrecords' || arr[i]=='nsms' || arr[i]=='ncontacts' ){
var cc=db.getCollection(arr[i]).find({$or:[{querytime:{$gte:timestamp,$lt:timestamp+86400}},{querytime:{$gte:timestamp+"",$lt:timestamp+86400+""}}]}).count();
}else{
var cc=db.getCollection(arr[i]).find({addtime:{$gte:timestamp,$lt:timestamp+86400}}).count();
}
print ('mongo'+','+dt+','+arr[i]+','+cc);
}

您可以选择一种方式赞助本站