public class View
extends java.lang.Object
List<Foo> list = db.view("example/foo")
.startKey("start-key")
.endKey("end-key")
.limit(10)
.includeDocs(true)
.query(Foo.class);
// scalar values
int count = db.view("example/by_tag")
.key("couchdb")
.queryForInt();
// pagination
Page<Foo> page = db.view("example/foo").queryPage(...);
CouchDatabaseBase.view(String)
,
ViewResult
Constructor and Description |
---|
View() |
Modifier and Type | Method and Description |
---|---|
View |
descending(java.lang.Boolean descending)
Reverses the reading direction, not the sort order.
|
View |
endKey(java.lang.Object... endKey) |
View |
endKeyDocId(java.lang.String endKeyDocId) |
View |
group(java.lang.Boolean group) |
View |
groupLevel(java.lang.Integer groupLevel) |
View |
includeDocs(java.lang.Boolean includeDocs) |
View |
inclusiveEnd(java.lang.Boolean inclusiveEnd) |
View |
key(java.lang.Object... key) |
View |
keys(java.util.List<java.lang.String> keys)
Supplies a key list when calling _all_docs View.
|
View |
limit(java.lang.Integer limit) |
<T> java.util.List<T> |
query(java.lang.Class<T> classOfT)
Queries a view.
|
boolean |
queryForBoolean() |
int |
queryForInt() |
long |
queryForLong() |
java.io.InputStream |
queryForStream()
Queries a view as an
InputStream |
java.lang.String |
queryForString() |
<T> Page<T> |
queryPage(int rowsPerPage,
java.lang.String param,
java.lang.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(java.lang.Class<K> classOfK,
java.lang.Class<V> classOfV,
java.lang.Class<T> classOfT)
Queries a view.
|
View |
reduce(java.lang.Boolean reduce) |
View |
skip(java.lang.Integer skip) |
View |
stale(java.lang.String stale) |
View |
startKey(java.lang.Object... startKey) |
View |
startKeyDocId(java.lang.String startKeyDocId) |
View |
updateSeq(java.lang.Boolean updateSeq) |
public java.io.InputStream queryForStream()
InputStream
The stream should be properly closed after usage, as to avoid connection leaks.
InputStream
.public <T> java.util.List<T> query(java.lang.Class<T> classOfT)
T
- Object type TclassOfT
- The class of type TList<T>
public <K,V,T> ViewResult<K,V,T> queryView(java.lang.Class<K> classOfK, java.lang.Class<V> classOfV, java.lang.Class<T> classOfT)
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.public int queryForInt()
public boolean queryForBoolean()
public View key(java.lang.Object... key)
key
- The key value, accepts a single value or multiple values for complex keys.public View startKey(java.lang.Object... startKey)
startKey
- The start key value, accepts a single value or multiple values for complex keys.public View startKeyDocId(java.lang.String startKeyDocId)
startKeyDocId
- public View endKey(java.lang.Object... endKey)
endKey
- The end key value, accepts a single value or multiple values for complex keys.public View endKeyDocId(java.lang.String endKeyDocId)
endKeyDocId
- public View descending(java.lang.Boolean descending)
public java.lang.String queryForString()
public View limit(java.lang.Integer limit)
limit
- public View group(java.lang.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 groupLevel(java.lang.Integer groupLevel)
groupLevel
- public long queryForLong()
public <T> Page<T> queryPage(int rowsPerPage, java.lang.String param, java.lang.Class<T> classOfT)
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.Page
public View stale(java.lang.String stale)
stale
- Accept values: ok | update_after (update_after as of CouchDB 1.1.0)public View skip(java.lang.Integer skip)
skip
- Skips n number of documents.public View reduce(java.lang.Boolean reduce)
reduce
- Indicates whether to use the reduce function of the view,
defaults to true if the reduce function is defined.public View includeDocs(java.lang.Boolean includeDocs)
includeDocs
- public View inclusiveEnd(java.lang.Boolean inclusiveEnd)
inclusiveEnd
- Indicates whether the endkey is included in the result,
defaults to true.public View updateSeq(java.lang.Boolean updateSeq)
updateSeq
- public View keys(java.util.List<java.lang.String> keys)
keys
-