use of com.couchbase.client.java.view.ViewQuery in project ff4j by ff4j.
the class EventRepositoryCouchbase method queryView.
public void queryView(Bucket bucket, String design, String view) {
ViewQuery queryAllFeatures = ViewQuery.from(design, view);
ViewResult queryResult = bucket.query(queryAllFeatures);
List<ViewRow> rows = queryResult.allRows();
for (ViewRow viewRow : rows) {
System.out.println("Result view:" + viewRow.id() + ":" + viewRow.value());
}
}
use of com.couchbase.client.java.view.ViewQuery in project tutorials by eugenp.
the class StudentGradeService method findTopGradesByCourse.
public List<JsonDocument> findTopGradesByCourse(String course, int limit) {
ViewQuery query = queryBuilder.findTopGradesByCourse(course, limit);
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 findByGradeInRange.
public List<JsonDocument> findByGradeInRange(int lower, int upper, boolean inclusiveEnd) {
ViewQuery query = queryBuilder.findByGradeInRange(lower, upper, inclusiveEnd);
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 sumCreditHoursByStudent.
public Map<String, Long> sumCreditHoursByStudent() {
ViewQuery query = ViewQuery.from("studentGrades", "sumHoursByStudent").reduce().groupLevel(1);
ViewResult result = bucket.query(query);
Map<String, Long> creditHoursByStudent = new HashMap<>();
for (ViewRow row : result.allRows()) {
String course = (String) row.key();
long sum = Long.valueOf(row.value().toString());
creditHoursByStudent.put(course, sum);
}
return creditHoursByStudent;
}
use of com.couchbase.client.java.view.ViewQuery in project tutorials by eugenp.
the class StudentGradeService method findByCourse.
public List<JsonDocument> findByCourse(String course) {
ViewQuery query = queryBuilder.findByCourse(course);
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
Aggregations