2015-07-20 142 views
0

是否可以將此mongo shell聚合查詢轉換爲spring-data?將mongodb聚合查詢轉換爲spring-data-mongodb

db.getCollection("X").aggregate([ 
    { 
     $group: { 
      _id: { 
       year: { 
        $year: "$happenedAt" 
       }, 
       month: { 
        $month: "$happenedAt" 
       }, 
       day: { 
        $dayOfMonth: "$happenedAt" 
       } 
      }, 
      count: { 
       $sum: 1 
      } 
     } 
    } 
]) 

感謝

回答

-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")); 

這就是它。