db.getCollection(‘CPU‘).find({}).limit(100).sort({"time":-1}).forEach(
function(a){
a["v"]=(new Date(a["time"]).toString());
printjson((a["v"]))
})
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()
db.getCollection(‘CPU‘).find({ $where: "this.time % 60 == 0" }).limit(360)
db.CPU.mapReduce(
function() {emit(this._id,this.time);},
function(key,values) {return Array.sum(values)},
{
query:{},
}
)
原文:http://www.cnblogs.com/yunpiao111/p/6294743.html