Allow clients to pass a db record to query_view
The recent updates to use couch_mrview prevented the use of a #db{}
record in concjunction with a binary GroupId because the ddoc_cache
doesn't extract the name from a db record and instead uses it as the key
directly.
diff --git a/src/fabric.erl b/src/fabric.erl
index 3bd45b8..ea07fbe 100644
--- a/src/fabric.erl
+++ b/src/fabric.erl
@@ -282,8 +282,9 @@
-spec query_view(dbname(), #doc{} | binary(), iodata(), callback(), any(),
#mrargs{}) ->
any().
-query_view(DbName, GroupId, ViewName, Callback, Acc0, QueryArgs)
+query_view(Db, GroupId, ViewName, Callback, Acc0, QueryArgs)
when is_binary(GroupId) ->
+ DbName = dbname(Db),
{ok, DDoc} = ddoc_cache:open(DbName, <<"_design/", GroupId/binary>>),
query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs);
query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs0) ->