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
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private String
private static final String
private static final String
private static final String
private CouchDbClientBase
private Boolean
private String
private String
private Boolean
private Integer
private com.google.gson.Gson
private Boolean
private Boolean
private String
private Integer
private static final org.apache.commons.logging.Log
private static final String
private static final String
private Boolean
private Integer
private String
private static final String
private static final String
private String
private String
private Boolean
private URIBuilder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondescending
(Boolean descending) Reverses the reading direction, not the sort order.endKeyDocId
(String endKeyDocId) private String
getKeyAsJson
(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.boolean
int
long
Queries a view as anInputStream
private <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 anull
param.private <T> Page
<T> queryPreviousPage
(int rowsPerPage, String currentStartKey, String currentStartKeyDocId, String startKey, String startKeyDocId, Class<T> classOfT) private <V> V
queryValue
(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 anInputStream
The 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.
-
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 anull
param.- Type Parameters:
T
- Object type T- Parameters:
rowsPerPage
- The number of rows per page.param
- The request parameter to use to query a page, ornull
to return the first page.classOfT
- The class of type T.- Returns:
Page
-
queryNextPage
private <T> Page<T> queryNextPage(int rowsPerPage, String currentStartKey, String currentStartKeyDocId, String startKey, String startKeyDocId, Class<T> classOfT) - Returns:
- The next page.
-
queryPreviousPage
private <T> Page<T> queryPreviousPage(int rowsPerPage, String currentStartKey, String currentStartKeyDocId, String startKey, String startKeyDocId, Class<T> classOfT) - Returns:
- The previous 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
-
getKeyAsJson
-