use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.
the class StudentGradeService method sumGradePointsByStudent.
public Map<String, Long> sumGradePointsByStudent() {
ViewQuery query = ViewQuery.from("studentGrades", "sumGradePointsByStudent").reduce().groupLevel(1);
ViewResult result = bucket.query(query);
Map<String, Long> gradePointsByStudent = new HashMap<>();
for (ViewRow row : result.allRows()) {
String course = (String) row.key();
long sum = Long.valueOf(row.value().toString());
gradePointsByStudent.put(course, sum);
}
return gradePointsByStudent;
}
use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.
the class StudentGradeService method findAll.
public List<JsonDocument> findAll() {
ViewQuery query = queryBuilder.findAll();
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.
the class StudentGradeService method findByCourseAndGradeInRange.
public List<JsonDocument> findByCourseAndGradeInRange(String course, int minGrade, int maxGrade, boolean inclusiveEnd) {
ViewQuery query = queryBuilder.findByCourseAndGradeInRange(course, minGrade, maxGrade, inclusiveEnd);
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.
the class StudentGradeService method findByGradeGreaterThan.
public List<JsonDocument> findByGradeGreaterThan(int lower) {
ViewQuery query = queryBuilder.findByGradeGreaterThan(lower);
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
Aggregations