couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [15/50] [abbrv] couch commit: updated refs/heads/import-rcouch to e2dbc79
Date Thu, 06 Feb 2014 17:39:57 GMT
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/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/4841f771
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/4841f771
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/4841f771

Branch: refs/heads/import-rcouch
Commit: 4841f771b9418cef0d36f8b889239d542d1cee6f
Parents: a64106d
Author: Klaus Trainer <klaus_trainer@posteo.de>
Authored: Fri Nov 15 17:02:20 2013 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Nov 28 22:59:13 2013 +0000

----------------------------------------------------------------------
 couch_changes.erl  | 16 +++++++++++++---
 couch_db.hrl       |  2 ++
 couch_httpd_db.erl |  6 ++++++
 3 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/4841f771/couch_changes.erl
----------------------------------------------------------------------
diff --git a/couch_changes.erl b/couch_changes.erl
index 85c9e54..6edde32 100644
--- a/couch_changes.erl
+++ b/couch_changes.erl
@@ -29,6 +29,7 @@
     resp_type,
     limit,
     include_docs,
+    doc_options,
     conflicts,
     timeout,
     timeout_fun
@@ -272,6 +273,7 @@ start_sending_changes(Callback, UserAcc, ResponseType) ->
 build_acc(Args, Callback, UserAcc, Db, StartSeq, Prepend, Timeout, TimeoutFun) ->
     #changes_args{
         include_docs = IncludeDocs,
+        doc_options = DocOpts,
         conflicts = Conflicts,
         limit = Limit,
         feed = ResponseType,
@@ -287,6 +289,7 @@ build_acc(Args, Callback, UserAcc, Db, StartSeq, Prepend, Timeout, TimeoutFun)
-
         resp_type = ResponseType,
         limit = Limit,
         include_docs = IncludeDocs,
+        doc_options = DocOpts,
         conflicts = Conflicts,
         timeout = Timeout,
         timeout_fun = TimeoutFun
@@ -498,7 +501,12 @@ changes_row(Results, DocInfo, Acc) ->
     #doc_info{
         id = Id, high_seq = Seq, revs = [#rev_info{deleted = Del} | _]
     } = DocInfo,
-    #changes_acc{db = Db, include_docs = IncDoc, conflicts = Conflicts} = Acc,
+    #changes_acc{
+        db = Db,
+        include_docs = IncDoc,
+        doc_options = DocOpts,
+        conflicts = Conflicts
+    } = Acc,
     {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>,
Results}] ++
         deleted_item(Del) ++ case IncDoc of
             true ->
@@ -508,8 +516,10 @@ changes_row(Results, DocInfo, Acc) ->
                 end,
                 Doc = couch_index_util:load_doc(Db, DocInfo, Opts),
                 case Doc of
-                    null -> [{doc, null}];
-                    _ ->  [{doc, couch_doc:to_json_obj(Doc, [])}]
+                    null ->
+                        [{doc, null}];
+                    _ ->
+                        [{doc, couch_doc:to_json_obj(Doc, DocOpts)}]
                 end;
             false ->
                 []

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/4841f771/couch_db.hrl
----------------------------------------------------------------------
diff --git a/couch_db.hrl b/couch_db.hrl
index 4036934..6888f10 100644
--- a/couch_db.hrl
+++ b/couch_db.hrl
@@ -219,6 +219,7 @@
 
     view_type = nil,
     include_docs = false,
+    doc_options = [],
     conflicts = false,
     stale = false,
     multi_get = false,
@@ -269,6 +270,7 @@
     filter_fun,
     filter_args = [],
     include_docs = false,
+    doc_options = [],
     conflicts = false,
     db_open_options = []
 }).

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/4841f771/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/couch_httpd_db.erl b/couch_httpd_db.erl
index f5fe483..0a7c17c 100644
--- a/couch_httpd_db.erl
+++ b/couch_httpd_db.erl
@@ -1141,6 +1141,12 @@ parse_changes_query(Req, Db) ->
             Args#changes_args{timeout=list_to_integer(Value)};
         {"include_docs", "true"} ->
             Args#changes_args{include_docs=true};
+        {"attachments", "true"} ->
+            Opts = Args#changes_args.doc_options,
+            Args#changes_args{doc_options=[attachments|Opts]};
+        {"att_encoding_info", "true"} ->
+            Opts = Args#changes_args.doc_options,
+            Args#changes_args{doc_options=[att_encoding_info|Opts]};
         {"conflicts", "true"} ->
             Args#changes_args{conflicts=true};
         {"filter", _} ->


Mime
View raw message