diff options
Diffstat (limited to 'src/fabric_rpc.erl')
-rw-r--r-- | src/fabric_rpc.erl | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl index c54ec247..75ce5e90 100644 --- a/src/fabric_rpc.erl +++ b/src/fabric_rpc.erl @@ -1,12 +1,31 @@ -module(fabric_rpc). --export([open_doc/3, open_doc/4, get_db_info/1, update_docs/3]). +-export([open_doc/3, open_doc/4, get_db_info/1, update_docs/3, + get_missing_revs/2]). +-include("../../couch/src/couch_db.hrl"). -include_lib("eunit/include/eunit.hrl"). + open_doc(DbName, DocId, Options) -> - io:format("~p ~p ~p ~p~n", [?MODULE, DbName, DocId, Options]), with_db(DbName, {couch_db, open_doc_int, [DocId, Options]}). +get_missing_revs(DbName, IdRevsList) -> + % reimplement here so we get [] for Ids with no missing revs in response + rexi:reply(case couch_db:open(DbName, []) of + {ok, Db} -> + Ids = [Id1 || {Id1, _Revs} <- IdRevsList], + {ok, lists:zipwith(fun({Id, Revs}, FullDocInfoResult) -> + case FullDocInfoResult of + {ok, #full_doc_info{rev_tree=RevisionTree}} -> + {Id, couch_key_tree:find_missing(RevisionTree, Revs)}; + not_found -> + {Id, Revs} + end + end, IdRevsList, couch_btree:lookup(Db#db.id_tree, Ids))}; + Error -> + Error + end). + %% rpc endpoints %% call to with_db will supply your M:F with a #db{} and then remaining args |