mongoDB projection、fields 指定字段返回

 java springjava

 

Query query = new Query();Criteria criteriaSn = Criteria.where("sn").is(sn);Criteria criteriaTime = Criteria.where("createTime").gte(timeBegin).lte(timeEnd);query.addCriteria(criteriaSn);query.addCriteria(criteriaTime);//指定返回字段query.fields().include("sLat");query.fields().include("sLon");query.fields().include("GLat");query.fields().include("GLon");query.fields().include("createTime");System.out.println(query.toString());//query.addCriteria(criteriaGLon.orOperator(criteriaSLon));//正序query.with(new Sort(new Order(Direction.ASC, "createTime")));List<DeviceData> list =  mongoTemplate.find(query, DeviceData.class,"deviceData");
相關文章
相關標籤/搜索