Package org.lightcouch
Class View
java.lang.Object
org.lightcouch.View
This class provides access to the View APIs.
Usage Example:
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(...);
- Since:
- 0.0.2
- Author:
- Ahmed Yehia
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondescending(Boolean descending) Reverses the reading direction, not the sort order.endKeyDocId(String endKeyDocId) groupLevel(Integer groupLevel) includeDocs(Boolean includeDocs) inclusiveEnd(Boolean inclusiveEnd) Supplies a key list when calling _all_docs View.<T> List<T> Queries a view.booleanintlongQueries a view as anInputStream<T> Page<T> 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 anullparam.<K,V, T> ViewResult <K, V, T> Queries a view.startKeyDocId(String startKeyDocId)
-
Method Details
-
queryForStream
Queries a view as anInputStreamThe stream should be properly closed after usage, as to avoid connection leaks.
- Returns:
- The result as an
InputStream.
-
query
Queries a view.- Type Parameters:
T- Object type T- Parameters:
classOfT- The class of type T- Returns:
- The result of the view query as a
List<T>
-
queryView
public <K,V, ViewResult<K,T> V, queryViewT> (Class<K> classOfK, Class<V> classOfV, Class<T> classOfT) Queries a view.- Type Parameters:
K- Object type K (key)V- Object type V (value)T- The class type- Parameters:
classOfK- The class of type K.classOfV- The class of type V.classOfT- The class of type T.- Returns:
- The View result entries.
-
queryForString
- Returns:
- The result of the view as String.
-
queryForInt
public int queryForInt()- Returns:
- The result of the view as int.
-
queryForLong
public long queryForLong()- Returns:
- The result of the view as long.
-
queryForBoolean
public boolean queryForBoolean()- Returns:
- The result of the view as boolean.
-
queryPage
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 anullparam.- Type Parameters:
T- Object type T- Parameters:
rowsPerPage- The number of rows per page.param- The request parameter to use to query a page, ornullto return the first page.classOfT- The class of type T.- Returns:
Page
-
key
- Parameters:
key- The key value, accepts a single value or multiple values for complex keys.- Returns:
View
-
startKey
- Parameters:
startKey- The start key value, accepts a single value or multiple values for complex keys.- Returns:
View
-
startKeyDocId
- Parameters:
startKeyDocId- The start key document id.- Returns:
View
-
endKey
- Parameters:
endKey- The end key value, accepts a single value or multiple values for complex keys.- Returns:
View
-
endKeyDocId
- Parameters:
endKeyDocId- The end key document id.- Returns:
View
-
limit
- Parameters:
limit- The limit value.- Returns:
View
-
stale
- Parameters:
stale- Accept values: ok | update_after (update_after as of CouchDB 1.1.0)- Returns:
View
-
descending
Reverses the reading direction, not the sort order.- Parameters:
descending- The descending value true | false- Returns:
View
-
skip
- Parameters:
skip- Skips n number of documents.- Returns:
View
-
group
- Parameters:
group- Specifies whether the reduce function reduces the result to a set of keys, or to a single result. Defaults to false (single result).- Returns:
View
-
groupLevel
- Parameters:
groupLevel- The group level- Returns:
View
-
reduce
- Parameters:
reduce- Indicates whether to use the reduce function of the view, defaults to true if the reduce function is defined.- Returns:
View
-
includeDocs
- Parameters:
includeDocs- Indicates whether to include documents- Returns:
View
-
inclusiveEnd
- Parameters:
inclusiveEnd- Indicates whether the endkey is included in the result, defaults to true.- Returns:
View
-
updateSeq
- Parameters:
updateSeq- Indicates whether to include sequence id of the view- Returns:
View
-
keys
Supplies a key list when calling _all_docs View.- Parameters:
keys- The list of keys- Returns:
View
-