@View(name = "by_nextFireTime", map = "function(doc) { if (doc.type === 'CouchDbTrigger' && doc.state === 'WAITING') emit(doc.next_fire_time, doc._id); }") public List<CouchDbTrigger> acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow) throws JobPersistenceException { logger.info("by_nextFireTime"); return db.queryView(createQuery("by_nextFireTime").startKey(new Date(0)).endKey(new Date(noLaterThan + timeWindow)).limit(maxCount).includeDocs(true), CouchDbTrigger.class); }
.includeDocs(true) .key(key) .startKey(startKey) .endKey(endKey);
.includeDocs(true) .key(key) .startKey(startKey) .endKey(endKey);
viewQuery.startKey(nextPageKey);
viewQuery.startKey(nextPageKey);
@View(name = "by_dueDate", map = "function(doc) { \n" + " if(doc.type === 'AppointmentCalendar') {\n" + " for(var i=0;i<doc.visits.length;i++) {\n" + " emit(doc.visits[i].appointment.dueDate,{\"externalId\" :doc.externalId,\"visit\" : doc.visits[i]});\n" + " }\n" + " }\n" + "}") public List<VisitResponse> findVisitsWithDueDateInRange(DateTime start, DateTime end) { ViewQuery query = createQuery("by_dueDate").startKey(setTimeZoneUTC(start)).endKey(setTimeZoneUTC(end)); List<VisitQueryResult> visitQueryResults = db.queryView(query, VisitQueryResult.class); return extractVisitResponse(visitQueryResults); }
@GenerateView public List<Alert> findByDateTime(DateTime fromDate, DateTime toDate) { ViewQuery q = createQuery("by_dateTime").startKey(setTimeZoneUTC(fromDate)).endKey(setTimeZoneUTC(toDate)).includeDocs(true); return db.queryView(q, Alert.class); } }
/** * Execute the query and return the result. */ @Override public Result<K, T> execute(Query<K, T> query) { query.setFields(getFieldsToQuery(query.getFields())); final ViewQuery viewQuery = new ViewQuery() .allDocs() .includeDocs(true) .startKey(query.getStartKey()) .endKey(query.getEndKey()) .limit(Ints.checkedCast(query.getLimit())); //FIXME GORA have long value but ektorp client use integer CouchDBResult<K, T> couchDBResult = new CouchDBResult<>(this, query, db.queryView(viewQuery, Map.class)); return couchDBResult; }
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; }
/** * Execute the query and return the result. */ @Override public Result<K, T> execute(Query<K, T> query) throws GoraException { try { query.setFields(getFieldsToQuery(query.getFields())); final ViewQuery viewQuery = new ViewQuery() .allDocs() .includeDocs(true) .startKey(query.getStartKey()) .endKey(query.getEndKey()) .limit(Ints.checkedCast(query.getLimit())); //FIXME GORA have long value but ektorp client use integer CouchDBResult<K, T> couchDBResult = new CouchDBResult<>(this, query, db.queryView(viewQuery, Map.class)); return couchDBResult; } catch (Exception e) { throw new GoraException(e) ; } }
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); }