是否可以将此mongo shell聚合查询转换为spring-data?
db.getCollection("X").aggregate([
{
$group: {
_id: {
year: {
$year: "$happenedAt"
},
month: {
$month: "$happenedAt"
},
day: {
$dayOfMonth: "$happenedAt"
}
},
count: {
$sum: 1
}
}
}
])
由于
答案 0 :(得分:-1)
Criteria c=new Criteria(Criteria.where("year").is(y).and("month").is(m).and("day").is(d));
Aggregration a=newAggregration(match(c),group("year","month","day").count().as("total"));
就是这样。