建议参考官方文档真详细
Spring Data MongoDB - Reference Documentation
mangodb模糊查询用法
使用Spring访问Mongodb的方法大全——Spring Data MongoDB查询指南 - JadePeng - 博客园
字段下面的list中字段值的查询判断
query.addCriteria(Criteria.where("rulesItem.bussinessType.value").regex(reqDTO.getBussinessType(), "i"));
spring-data-mongodb之Aggregation -
排序后取出第一个
User findFirstByOrderByLastnameAsc();
User findTopByOrderByAgeDesc();
Page
Slice
List
List
mango做聚合操作
mango
db.getCollection('agent').aggregate([ {$group: {_id : {"officeCode":"$officeCode", "segOrgn":"$segOrgn","segDstn:$segDstn"}, num: {$sum : 1}}} ])
java
public List
{
Aggregation aggregation1 = Aggregation.newAggregation(Aggregation.group("officeCode:$officeCode","segOrgn:$segOrgn","segDstn:$segDstn").count().as("num"));
AggregationResults
mongoTemplate.aggregate(aggregation1, "agent", AgentDO1.class);
List
return tagCount;
}
mango有子列表做聚合操作
public List
Aggregation aggregation1 = Aggregation.newAggregation(Aggregation.unwind("resultList"),
Aggregation.group("startDate:$startDate","endDate:$endDate","officeCode:$resultList.officeCode", "segOrgn:$resultList.segOrgn", "segDstn:$resultList.segDstn").count().as("num"));
AggregationResults
"sales_exception", SalesExceptionResultDO1.class);
List
return tagCount;
}