mongoTemplate操作MongoDB排序

 解决项目中遇到的排序问题,Mark一下!!

  @Override
    public List findStep(StepRequest stepRequest) throws ParseException {
        Query query = new Query(Criteria.where("device_id").is(stepRequest.getDeviceId()).and("create_time").gte(sdf.parse(stepRequest.getStartDate())).lte(sdf.parse(stepRequest.getEndDate())));
        query.with(new Sort(new Sort.Order(Sort.Direction.ASC,"create_time")));
        List list = mongoTemplate.find(query, TrackerInfo.class);
        return list;
    }

 

你可能感兴趣的:(MongoDB,MongoDB)