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
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate CouchDbClientBaseprivate Booleanprivate Stringprivate Stringprivate Booleanprivate Integerprivate com.google.gson.Gsonprivate Booleanprivate Booleanprivate Stringprivate Integerprivate static final org.apache.commons.logging.Logprivate static final Stringprivate static final Stringprivate Booleanprivate Integerprivate Stringprivate static final Stringprivate static final Stringprivate Stringprivate Stringprivate Booleanprivate URIBuilder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondescending(Boolean descending) Reverses the reading direction, not the sort order.endKeyDocId(String endKeyDocId) private StringgetKeyAsJson(Object... key) 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 anInputStreamprivate <T> Page<T> queryNextPage(int rowsPerPage, String currentStartKey, String currentStartKeyDocId, String startKey, String startKeyDocId, Class<T> classOfT) <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.private <T> Page<T> queryPreviousPage(int rowsPerPage, String currentStartKey, String currentStartKeyDocId, String startKey, String startKeyDocId, Class<T> classOfT) private <V> VqueryValue(Class<V> classOfV) Queries for scalar values.<K,V, T> ViewResult <K, V, T> Queries a view.startKeyDocId(String startKeyDocId)
-
Field Details
-
log
private static final org.apache.commons.logging.Log log -
START_KEY
- See Also:
-
START_KEY_DOC_ID
- See Also:
-
CURRENT_START_KEY
- See Also:
-
CURRENT_START_KEY_DOC_ID
- See Also:
-
CURRENT_KEYS
- See Also:
-
ACTION
- See Also:
-
NEXT
- See Also:
-
PREVIOUS
- See Also:
-
key
-
startKey
-
startKeyDocId
-
endKey
-
endKeyDocId
-
limit
-
stale
-
descending
-
skip
-
group
-
groupLevel
-
reduce
-
includeDocs
-
inclusiveEnd
-
updateSeq
-
dbc
-
gson
private com.google.gson.Gson gson -
uriBuilder
-
allDocsKeys
-
-
Constructor Details
-
View
View(CouchDbClientBase dbc, String viewId)
-
-
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
-
queryView
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.
-
queryValue
Queries for scalar values. Internal use. -
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
-
queryNextPage
-
queryPreviousPage
-
key
-
startKey
-
startKeyDocId
-
endKey
-
endKeyDocId
-
limit
-
stale
-
descending
-
skip
-
group
-
groupLevel
-
reduce
-
includeDocs
-
inclusiveEnd
-
updateSeq
-
keys
-
getKeyAsJson
-