Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

CouchDbConnector queryView(ViewQuery query) vs. queryView(ViewQuery query, Class<T> type) #85

@bhaskarmurthy

Description

@bhaskarmurthy

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions