diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-09-16 22:04:18 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-09-16 22:04:18 +0000 |
commit | 926af4ba11093dcaff13bea0e4ed9addfc67ab10 (patch) | |
tree | 40bec2163d0028d3e676eb0b47cebb634957c556 /src/couchdb | |
parent | 3be897ebad528a81bcec91c406ea4e390f8a2915 (diff) |
include_docs now take an _id (as well as a _rev) in the emitted value, to load docs other than the one doing the emitting. This means you can have one doc list a set of other docs to load in a single query. Enjoy!
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@815984 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 2 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_view.erl | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 03093c41..cdc74610 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -192,7 +192,7 @@ changes_enumerator(DocInfos, {Db, _, Prepend, FilterFun, Resp, _, Limit, Include changes_row(Db, Seq, Id, Del, Results, Rev, true) -> {[{seq,Seq},{id,Id},{changes,Results}] ++ deleted_item(Del) ++ - couch_httpd_view:doc_member(Db, Id, Rev)}; + couch_httpd_view:doc_member(Db, {Id, Rev})}; changes_row(_, Seq, Id, Del, Results, _, false) -> {[{seq,Seq},{id,Id},{changes,Results}] ++ deleted_item(Del)}. diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl index 531e3b6c..489df0a2 100644 --- a/src/couchdb/couch_httpd_view.erl +++ b/src/couchdb/couch_httpd_view.erl @@ -18,7 +18,7 @@ -export([get_stale_type/1, get_reduce_type/1, parse_view_params/3]). -export([make_view_fold_fun/6, finish_view_fold/4, view_row_obj/3]). -export([view_group_etag/2, view_group_etag/3, make_reduce_fold_funs/5]). --export([design_doc_view/5, parse_bool_param/1, doc_member/3]). +-export([design_doc_view/5, parse_bool_param/1, doc_member/2]). -export([make_key_options/1]). -import(couch_httpd, @@ -589,17 +589,18 @@ view_row_obj(Db, {{Key, DocId}, {Props}}, true) -> Rev0 -> couch_doc:parse_rev(Rev0) end, - view_row_with_doc(Db, {{Key, DocId}, {Props}}, Rev); + IncludeId = proplists:get_value(<<"_id">>, Props, DocId), + view_row_with_doc(Db, {{Key, DocId}, {Props}}, {IncludeId, Rev}); view_row_obj(Db, {{Key, DocId}, Value}, true) -> - view_row_with_doc(Db, {{Key, DocId}, Value}, nil); + view_row_with_doc(Db, {{Key, DocId}, Value}, {DocId, nil}); % the normal case for rendering a view row view_row_obj(_Db, {{Key, DocId}, Value}, _IncludeDocs) -> {[{id, DocId}, {key, Key}, {value, Value}]}. -view_row_with_doc(Db, {{Key, DocId}, Value}, Rev) -> - {[{id, DocId}, {key, Key}, {value, Value}] ++ doc_member(Db, DocId, Rev)}. +view_row_with_doc(Db, {{Key, DocId}, Value}, IdRev) -> + {[{id, DocId}, {key, Key}, {value, Value}] ++ doc_member(Db, IdRev)}. -doc_member(Db, DocId, Rev) -> +doc_member(Db, {DocId, Rev}) -> ?LOG_DEBUG("Include Doc: ~p ~p", [DocId, Rev]), case (catch couch_httpd_db:couch_doc_open(Db, DocId, Rev, [])) of #doc{} = Doc -> |