You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/06 17:54:31 UTC
[12/22] couch-mrview commit: updated refs/heads/import-rcouch to
7258945
Extend support for attachment-related query params
Until now, the boolean query parameters `attachments` and
`att_encoding_info` have only been supported for the document API
endpoint (`/{db}/{docid}`).
This extends support for queries to the changes (`/{db}/_changes`) and
view (`/{db}/_design/{ddoc}/_view/{view}`) API endpoints:
* If `include_docs` and `attachments` equal `true`, the Base64-encoded
contents of attachments are included with the documents in changes or
view query results, respectively.
* If `include_docs` and `att_encoding_info` equal `true`, encoding
information is included in attachment stubs if the particular
attachment is compressed.
Closes COUCHDB-1923.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/e650b435
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/e650b435
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/e650b435
Branch: refs/heads/import-rcouch
Commit: e650b435835b1aad9b394c2de675ec571c97a4a4
Parents: f5c829f
Author: Klaus Trainer <kl...@posteo.de>
Authored: Fri Nov 15 17:02:20 2013 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Thu Nov 28 22:59:13 2013 +0000
----------------------------------------------------------------------
include/couch_mrview.hrl | 1 +
src/couch_mrview_http.erl | 16 ++++++++++++++++
src/couch_mrview_util.erl | 22 +++++++++++-----------
3 files changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/e650b435/include/couch_mrview.hrl
----------------------------------------------------------------------
diff --git a/include/couch_mrview.hrl b/include/couch_mrview.hrl
index bf3bcac..e4ec66d 100644
--- a/include/couch_mrview.hrl
+++ b/include/couch_mrview.hrl
@@ -72,6 +72,7 @@
stale = false,
inclusive_end = true,
include_docs = false,
+ doc_options = [],
update_seq=false,
conflicts,
callback,
http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/e650b435/src/couch_mrview_http.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_http.erl b/src/couch_mrview_http.erl
index 8b914ef..7b92034 100644
--- a/src/couch_mrview_http.erl
+++ b/src/couch_mrview_http.erl
@@ -348,6 +348,22 @@ parse_qs(Key, Val, Args) ->
Args#mrargs{inclusive_end=parse_boolean(Val)};
"include_docs" ->
Args#mrargs{include_docs=parse_boolean(Val)};
+ "attachments" ->
+ case parse_boolean(Val) of
+ true ->
+ Opts = Args#mrargs.doc_options,
+ Args#mrargs{doc_options=[attachments|Opts]};
+ false ->
+ Args
+ end;
+ "att_encoding_info" ->
+ case parse_boolean(Val) of
+ true ->
+ Opts = Args#mrargs.doc_options,
+ Args#mrargs{doc_options=[att_encoding_info|Opts]};
+ false ->
+ Args
+ end;
"update_seq" ->
Args#mrargs{update_seq=parse_boolean(Val)};
"conflicts" ->
http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/e650b435/src/couch_mrview_util.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_util.erl b/src/couch_mrview_util.erl
index 18185af..a3b0581 100644
--- a/src/couch_mrview_util.erl
+++ b/src/couch_mrview_util.erl
@@ -668,24 +668,24 @@ expand_dups([KV | Rest], Acc) ->
maybe_load_doc(_Db, _DI, #mrargs{include_docs=false}) ->
[];
-maybe_load_doc(Db, #doc_info{}=DI, #mrargs{conflicts=true}) ->
- doc_row(couch_index_util:load_doc(Db, DI, [conflicts]));
-maybe_load_doc(Db, #doc_info{}=DI, _Args) ->
- doc_row(couch_index_util:load_doc(Db, DI, [])).
+maybe_load_doc(Db, #doc_info{}=DI, #mrargs{conflicts=true, doc_options=Opts}) ->
+ doc_row(couch_index_util:load_doc(Db, DI, [conflicts]), Opts);
+maybe_load_doc(Db, #doc_info{}=DI, #mrargs{doc_options=Opts}) ->
+ doc_row(couch_index_util:load_doc(Db, DI, []), Opts).
maybe_load_doc(_Db, _Id, _Val, #mrargs{include_docs=false}) ->
[];
-maybe_load_doc(Db, Id, Val, #mrargs{conflicts=true}) ->
- doc_row(couch_index_util:load_doc(Db, docid_rev(Id, Val), [conflicts]));
-maybe_load_doc(Db, Id, Val, _Args) ->
- doc_row(couch_index_util:load_doc(Db, docid_rev(Id, Val), [])).
+maybe_load_doc(Db, Id, Val, #mrargs{conflicts=true, doc_options=Opts}) ->
+ doc_row(couch_index_util:load_doc(Db, docid_rev(Id, Val), [conflicts]), Opts);
+maybe_load_doc(Db, Id, Val, #mrargs{doc_options=Opts}) ->
+ doc_row(couch_index_util:load_doc(Db, docid_rev(Id, Val), []), Opts).
-doc_row(null) ->
+doc_row(null, _Opts) ->
[{doc, null}];
-doc_row(Doc) ->
- [{doc, couch_doc:to_json_obj(Doc, [])}].
+doc_row(Doc, Opts) ->
+ [{doc, couch_doc:to_json_obj(Doc, Opts)}].
docid_rev(Id, {Props}) ->