ao查询
1
Group group = Group.keyFunction(keyfun.toString()).initial("count", 0).initial("total", 0)
2
.reduce(reduce.toString()).finalizeFunction(finalize.toString());
3
//调用自己封装的dao来实现 , 并输出结果
4
List
5
for (Map map : list) {
6
System.out.println(map);
7
}
封装的查询条件 :
www.2cto.com
1
{ "$regex" : { "$regex" : "^hexin" , "$options" : "m"}}
封装的group命令
01
{
02
"group": {
03
"$keyf": "function(d) { return { goup : d.group , d_o_f: d.date.getDay() } ; }",
04
"$reduce": "function ( curr, result) {result.total += curr.value; result.count++;}",
05
"initial": {
06
"total": 0,
07
"count": 0
08
},
09
"finalize": "function(result){
10
var weekdays = [ '星期天', '星期一', '星期二','星期三', '星期四','星期五', '星期六' ];
11
result.d_o_f = weekdays[result.d_o_f];
12
result.avg = Math.round(result.total / result.count);
13
}",
14
"ns": "c",
15
"cond": {
16
"name": {
17
"$regex": {
18
"$regex": "^hexin",
19
"$options": "m"
20
}
21
}
22
}
23
}
24
}
/////查询结果
{goup=0.0, d_o_f=星期三, total=63.0, count=7.0, avg=9.0}
{goup=1.0, d_o_f=星期三, total=70.0, count=7.0, avg=10.0}
{goup=2.0, d_o_f=星期三, total=57.0, count=6.0, avg=10.0}