use of com.couchbase.client.java.view.ViewQuery in project tutorials by eugenp.
the class StudentGradeService method findByGradeLessThan.
public List<JsonDocument> findByGradeLessThan(int upper) {
ViewQuery query = queryBuilder.findByGradeLessThan(upper);
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
use of com.couchbase.client.java.view.ViewQuery in project tutorials by eugenp.
the class StudentGradeService method findByCourses.
public List<JsonDocument> findByCourses(String... courses) {
ViewQuery query = queryBuilder.findByCourses(courses);
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
use of com.couchbase.client.java.view.ViewQuery in project tutorials by eugenp.
the class StudentGradeService method countStudentsByCourse.
public Map<String, Long> countStudentsByCourse() {
ViewQuery query = ViewQuery.from("studentGrades", "countStudentsByCourse").reduce().groupLevel(1);
ViewResult result = bucket.query(query);
Map<String, Long> numStudentsByCourse = new HashMap<>();
for (ViewRow row : result.allRows()) {
JsonArray keyArray = (JsonArray) row.key();
String course = keyArray.getString(0);
long count = Long.valueOf(row.value().toString());
numStudentsByCourse.put(course, count);
}
return numStudentsByCourse;
}
use of com.couchbase.client.java.view.ViewQuery 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.ViewQuery 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);
}
Aggregations