public class View extends Object
List<Foo> list = dbClient.view("example/foo")
.startKey("start-key")
.endKey("end-key")
.limit(10)
.includeDocs(true)
.query(Foo.class);
// scalar values
int count = dbClient.view("example/by_tag")
.key("couchdb")
.queryForInt();
// pagination
Page<Foo> page = dbClient.view("example/foo").queryPage(...);
CouchDbClientBase.view(String),
ViewResult| Modifier and Type | Method and Description |
|---|---|
View |
descending(Boolean descending)
Reverses the reading direction, not the sort order.
|
View |
endKey(Object... endKey) |
View |
endKeyDocId(String endKeyDocId) |
View |
group(Boolean group) |
View |
groupLevel(Integer groupLevel) |
View |
includeDocs(Boolean includeDocs) |
View |
inclusiveEnd(Boolean inclusiveEnd) |
View |
key(Object... key) |
View |
keys(List<String> keys) |
View |
limit(Integer limit) |
<T> List<T> |
query(Class<T> classOfT)
Queries a view.
|
boolean |
queryForBoolean() |
int |
queryForInt() |
long |
queryForLong() |
InputStream |
queryForStream()
Queries a view as an
InputStream |
String |
queryForString() |
<T> Page<T> |
queryPage(int rowsPerPage,
String param,
Class<T> classOfT)
Queries a view for pagination, returns a next or a previous page, this method
figures out which page to return based on the given param that is generated by an
earlier call to this method, quering the first page is done by passing a
null param. |
<K,V,T> ViewResult<K,V,T> |
queryView(Class<K> classOfK,
Class<V> classOfV,
Class<T> classOfT)
Queries a view.
|
View |
reduce(Boolean reduce) |
View |
skip(Integer skip) |
View |
stale(String stale) |
View |
startKey(Object... startKey) |
View |
startKeyDocId(String startKeyDocId) |
View |
tempView(DesignDocument.MapReduce mapReduce) |
View |
tempView(String id) |
View |
updateSeq(Boolean updateSeq) |
public InputStream queryForStream() throws UnsupportedEncodingException
InputStream
The stream should be properly closed after usage, as to avoid connection leaks.
InputStream.UnsupportedEncodingExceptionpublic <T> List<T> query(Class<T> classOfT) throws UnsupportedEncodingException
T - Object type TclassOfT - The class of type TList<T> UnsupportedEncodingExceptionpublic <K,V,T> ViewResult<K,V,T> queryView(Class<K> classOfK, Class<V> classOfV, Class<T> classOfT) throws UnsupportedEncodingException
K - Object type K (key)V - Object type V (value)classOfK - The class of type K.classOfV - The class of type V.classOfT - The class of type T.UnsupportedEncodingExceptionpublic String queryForString() throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic int queryForInt()
throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic long queryForLong()
throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic boolean queryForBoolean()
throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic <T> Page<T> queryPage(int rowsPerPage, String param, Class<T> classOfT) throws UnsupportedEncodingException
null param.T - Object type TrowsPerPage - The number of rows per page.param - The request parameter to use to query a page, or null to return the first page.classOfT - The class of type T.PageUnsupportedEncodingExceptionpublic View key(Object... key)
key - The key value, accepts a single value or multiple values for complex keys.public View startKey(Object... startKey)
startKey - The start key value, accepts a single value or multiple values for complex keys.public View endKey(Object... endKey)
endKey - The end key value, accepts a single value or multiple values for complex keys.public View stale(String stale)
stale - Accept values: ok | update_after (update_after as of CouchDB 1.1.0)public View descending(Boolean descending)
public View group(Boolean group)
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 reduce(Boolean reduce)
reduce - Indicates whether to use the reduce function of the view,
defaults to true if the reduce function is defined.public View inclusiveEnd(Boolean inclusiveEnd)
inclusiveEnd - Indicates whether the endkey is included in the result,
defaults to true.public View tempView(DesignDocument.MapReduce mapReduce)
Copyright © 2011–2016. All rights reserved.