This repository was archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
CouchDbConnector queryView(ViewQuery query) vs. queryView(ViewQuery query, Class<T> type) #85
Copy link
Copy link
Open
Labels
Description
When running a query using queryView(ViewQuery)
, I get the right results in ViewResult
. However, when using queryView(ViewQuery, Class<T>)
, I get 0 results.
My TDView looks like:
TDView taskGroupAllView = db.getViewNamed("TaskGroup/all");
taskGroupAllView.setMapReduceBlocks(new TDViewMapBlock() {
@Override
public void map(Map<String, Object> document, TDViewMapEmitBlock emitter) {
Object type = document.get("type");
Object groupId = document.get("groupId");
Object createdAt = document.get("createdAt");
if (type != null && type.equals(TaskGroup.ITEM_TYPE)) {
ComplexKey key = ComplexKey.of(groupId, createdAt);
emitter.emit(key, document.get("_id"));
}
}
}, null, "1.0");
My repository looks like:
public class TaskGroupRepository extends CouchDbRepositorySupport<TaskGroup> {
public TaskGroupRepository(CouchDbConnector db) {
super(TaskGroup.class, db);
}
public List<TaskGroup> getAllByGroupId(String groupId) {
ViewQuery query = createQuery("all")
.descending(true)
.startKey(ComplexKey.of(groupId, ComplexKey.emptyObject()))
.endKey(ComplexKey.of(groupId));
return db.queryView(query, TaskGroup.class);
}
}
Result from queryView(ViewQuery) looks like:
ignoreNotFound = false
offset = 0
rows = [org.ektorp.ViewResult$Row@4155a408, org.ektorp.ViewResult$Row@4156a648]
totalRows = 2
updateSeq = null
Result from queryView(ViewQuery, Class) looks like:
modCount = 0
Is there a discrepancy in behaviour of these methods? Or could there be an issue in the mapping?