/** * Queries a view as an {@link InputStream} * * <p>The stream should be properly closed after usage, as to avoid connection leaks. * * @return The result as an {@link InputStream}. */ public InputStream queryForStream() { URI uri = uriBuilder.build(); if (allDocsKeys != null) { // bulk docs return getStream(dbc.post(uri, allDocsKeys)); } if (mapRedtempViewM != null) { // temp view return getStream(dbc.post(uri, gson.toJson(mapRedtempViewM))); } return dbc.get(uri); }
View(CouchDbClientBase dbc, String viewId) { assertNotEmpty(viewId, "View id"); this.dbc = dbc; this.gson = dbc.getGson(); String view = viewId; if (viewId.contains("/")) { String[] v = viewId.split("/"); view = String.format("_design/%s/_view/%s", v[0], v[1]); } this.uriBuilder = URIBuilder.buildUri(dbc.getDBUri()).path(view); }
public View includeDocs(Boolean includeDocs) { this.includeDocs = includeDocs; uriBuilder.query("include_docs", this.includeDocs); return this; }
/** * @param reduce Indicates whether to use the reduce function of the view, defaults to true if the * reduce function is defined. */ public View reduce(Boolean reduce) { this.reduce = reduce; uriBuilder.query("reduce", this.reduce); return this; }
public View groupLevel(Integer groupLevel) { this.groupLevel = groupLevel; uriBuilder.query("group_level", this.groupLevel); return this; }
/** * @param group Specifies whether the reduce function reduces the result to a set of keys, or to a * single result. Defaults to false (single result). */ public View group(Boolean group) { this.group = group; uriBuilder.query("group", this.group); return this; }
/** @param skip Skips <i>n</i> number of documents. */ public View skip(Integer skip) { this.skip = skip; uriBuilder.query("skip", this.skip); return this; }
/** Reverses the reading direction, not the sort order. */ public View descending(Boolean descending) { this.descending = Boolean.valueOf(gson.toJson(descending)); uriBuilder.query("descending", this.descending); return this; }
public View limit(Integer limit) { this.limit = limit; uriBuilder.query("limit", this.limit); return this; }
public View endKeyDocId(String endKeyDocId) { this.endKeyDocId = endKeyDocId; uriBuilder.query("endkey_docid", this.endKeyDocId); return this; }
/** * @param endKey The end key value, accepts a single value or multiple values for complex keys. */ public View endKey(Object... endKey) { this.endKey = getKeyAsJson(endKey); uriBuilder.query("endkey", this.endKey); return this; }
public View startKeyDocId(String startKeyDocId) { this.startKeyDocId = startKeyDocId; uriBuilder.query("startkey_docid", this.startKeyDocId); return this; }
/** * @param startKey The start key value, accepts a single value or multiple values for complex * keys. */ public View startKey(Object... startKey) { this.startKey = getKeyAsJson(startKey); uriBuilder.query("startkey", this.startKey); return this; }
/** @param key The key value, accepts a single value or multiple values for complex keys. */ public View key(Object... key) { this.key = getKeyAsJson(key); uriBuilder.query("key", this.key); return this; }
/** * @param inclusiveEnd Indicates whether the endkey is included in the result, defaults to true. */ public View inclusiveEnd(Boolean inclusiveEnd) { this.inclusiveEnd = inclusiveEnd; uriBuilder.query("inclusive_end", this.inclusiveEnd); return this; }
public View updateSeq(Boolean updateSeq) { this.updateSeq = updateSeq; uriBuilder.query("update_seq", this.updateSeq); return this; }
/** @param stale Accept values: ok | update_after (update_after as of CouchDB 1.1.0) */ public View stale(String stale) { this.stale = stale; uriBuilder.query("stale", this.stale); return this; }