summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/chttpd/src/chttpd_db.erl30
-rw-r--r--src/fabric/src/fabric2_util.erl38
2 files changed, 39 insertions, 29 deletions
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 174d46487..e9b33f001 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -867,7 +867,7 @@ all_docs_view(Req, Db, Keys, OP) ->
send_all_docs(Db, #mrargs{keys = undefined} = Args, VAcc0) ->
- Opts0 = all_docs_view_opts(Args),
+ Opts0 = fabric2_util:all_docs_view_opts(Args),
Opts = Opts0 ++ [{restart_tx, true}],
NS = couch_util:get_value(namespace, Opts),
FoldFun = case NS of
@@ -939,34 +939,6 @@ send_all_docs_keys(Db, #mrargs{} = Args, VAcc0) ->
end, VAcc1, Keys).
-all_docs_view_opts(Args) ->
- NS = couch_util:get_value(namespace, Args#mrargs.extra),
- StartKey = case Args#mrargs.start_key of
- undefined -> Args#mrargs.start_key_docid;
- SKey -> SKey
- end,
- EndKey = case Args#mrargs.end_key of
- undefined -> Args#mrargs.end_key_docid;
- EKey -> EKey
- end,
- StartKeyOpts = case StartKey of
- undefined -> [];
- _ -> [{start_key, fabric2_util:encode_all_doc_key(StartKey)}]
- end,
- EndKeyOpts = case {EndKey, Args#mrargs.inclusive_end} of
- {undefined, _} -> [];
- {_, false} -> [{end_key_gt, fabric2_util:encode_all_doc_key(EndKey)}];
- {_, true} -> [{end_key, fabric2_util:encode_all_doc_key(EndKey)}]
- end,
- [
- {dir, Args#mrargs.direction},
- {limit, Args#mrargs.limit},
- {skip, Args#mrargs.skip},
- {update_seq, Args#mrargs.update_seq},
- {namespace, NS}
- ] ++ StartKeyOpts ++ EndKeyOpts.
-
-
apply_args_to_keylist(Args, Keys0) ->
Keys1 = case Args#mrargs.direction of
fwd -> Keys0;
diff --git a/src/fabric/src/fabric2_util.erl b/src/fabric/src/fabric2_util.erl
index d74ef2718..97bfedc2c 100644
--- a/src/fabric/src/fabric2_util.erl
+++ b/src/fabric/src/fabric2_util.erl
@@ -38,6 +38,7 @@
uuid/0,
encode_all_doc_key/1,
+ all_docs_view_opts/1,
pmap/2,
pmap/3
@@ -45,6 +46,7 @@
-include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
revinfo_to_revs(RevInfo) ->
@@ -299,6 +301,42 @@ encode_all_doc_key(Term) when Term < <<>> -> <<>>;
encode_all_doc_key(_) -> <<255>>.
+all_docs_view_opts(#mrargs{} = Args) ->
+ NS = couch_util:get_value(namespace, Args#mrargs.extra),
+ StartKey = case Args#mrargs.start_key of
+ undefined -> Args#mrargs.start_key_docid;
+ SKey -> SKey
+ end,
+ EndKey = case Args#mrargs.end_key of
+ undefined -> Args#mrargs.end_key_docid;
+ EKey -> EKey
+ end,
+ StartKeyOpts = case StartKey of
+ undefined -> [];
+ _ -> [{start_key, encode_all_doc_key(StartKey)}]
+ end,
+ EndKeyOpts = case {EndKey, Args#mrargs.inclusive_end} of
+ {undefined, _} -> [];
+ {_, false} -> [{end_key_gt, encode_all_doc_key(EndKey)}];
+ {_, true} -> [{end_key, encode_all_doc_key(EndKey)}]
+ end,
+
+ DocOpts = case Args#mrargs.conflicts of
+ true -> [conflicts | Args#mrargs.doc_options];
+ _ -> Args#mrargs.doc_options
+ end,
+
+ [
+ {dir, Args#mrargs.direction},
+ {limit, Args#mrargs.limit},
+ {skip, Args#mrargs.skip},
+ {update_seq, Args#mrargs.update_seq},
+ {namespace, NS},
+ {include_docs, Args#mrargs.include_docs},
+ {doc_opts, DocOpts}
+ ] ++ StartKeyOpts ++ EndKeyOpts.
+
+
pmap(Fun, Args) ->
pmap(Fun, Args, []).