query = new ViewQuery().designDocId(designDocumentName).viewName(viewName).descending(descending);
query = new ViewQuery().designDocId(designDocumentName).viewName(viewName).descending(descending);
public static ViewQuery applyPagingParameters(ViewQuery q, PageRequest pr) { ViewQuery pagedQuery = q.clone(); if (pr.page > 0) { if (pr.getStartKey() != null) { pagedQuery.startKey(pr.getStartKey()); } if (pr.getStartKeyDocId() != null) { pagedQuery.startDocId(pr.getStartKeyDocId()); } if (pr.back) { pagedQuery.descending(!pagedQuery.isDescending()); } } int additionalRowsToQuery = 1; pagedQuery.limit(pr.getPageSize() + additionalRowsToQuery); return pagedQuery; }
private ViewQuery createBackReferenceQuery(String thisId, DocumentReferences ann, String fieldName) { boolean desc = ann.descendingSortOrder(); ComplexKey start = ComplexKey.of(thisId, fieldName); ComplexKey end = ComplexKey.of(thisId, fieldName, ComplexKey.emptyObject()); if (desc) { ComplexKey tmp = start; start = end; end = tmp; } return new ViewQuery().designDocId(resolveDesignDocId(ann)) .viewName(resolveViewName(ann, fieldName)) .includeDocs(true) .descending(ann.descendingSortOrder()).startKey(start) .endKey(end); }