如何利用spring data mongodb 进行多条件查询
1个回答
展开全部
@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()); }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询