如何利用spring data mongodb 进行多条件查询
1个回答
2015-09-04
展开全部
@Override
public long findBlogTodayAcceccCountByUserId(String userId) {
Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date todayStart = calendar.getTime();
calendar.add(Calendar.DATE, 1);
Date endStart = calendar.getTime();
Query query = new Query();
Criteria criteria = Criteria.where("createTime").gte(todayStart).lte(endStart);
query.addCriteria(criteria);
return mongoTemplate.count(query, getEntityClass());
}
public long findBlogTodayAcceccCountByUserId(String userId) {
Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date todayStart = calendar.getTime();
calendar.add(Calendar.DATE, 1);
Date endStart = calendar.getTime();
Query query = new Query();
Criteria criteria = Criteria.where("createTime").gte(todayStart).lte(endStart);
query.addCriteria(criteria);
return mongoTemplate.count(query, getEntityClass());
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询