统计脚本。
多表扫描:
function fu() {
for(var i=0; i<32; i++){
var r = db.getCollection('device'+i).find({},{"deviceToken":1});
// print(r.count());
for(var j=0; j < r.count(); j++) {
// printjson(r[j]);
printjsononeline(r[j]);
}
}
}
fu();
function fu() {
for(var i=0; i<32; i++){
var r = db.getCollection('device'+i).find({},{"userId":1,"deviceToken":1});
// print(r.count());
for(var j=0; j < r.count(); j++) {
printjsononeline(r[j]);
}
}
}
fu();
统计
function groupChatCount(){
var count = 0;
var rows = db.historyGroup.find();
for(var i=0, len = rows.length(); i < len; i++){
count = count + rows[i].msgCount;
}
print("groupChat:" + count);
}
groupChatCount();
function chatCount(){
var count = 0;
var rows = db.historyOneToOne.find();
for(var i=0, len = rows.length(); i < len; i++){
count = count + rows[i].msgCount;
}
print("chat:" + count);
}
chatCount();
// 多表统计
function notify(){
var tables = new Array()
for(var i = 0; i < 64; i++){
tables.push("notifyMessageNew" + i);
}
var count = 0;
for(var i = 0; i < tables.length; i++){
count = count + db.getCollection(tables[i]).count();
}
print("notify:" + count);
}
// 多表统计
function notify(){
var count = 0;
for(var i = 0; i < 64; i++){
var v = db.getCollection('notifyMessageNew'+i).count();
count = count + v;
}
print("notify:" + count);
}
function deleCollection(){
for(var i = 0; i < 1024; i++){
db.getCollection('idvalue'+i).drop();
}
print("success");
}
deleCollection();