summaryrefslogtreecommitdiff
path: root/src/fabric_rpc.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-05-28 15:21:42 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-05-28 15:21:42 -0400
commit46273631d3496586bfb1fa1713c2e9b8484bec61 (patch)
treea0daf081668002e354d40b9339cdda3daa97fd9e /src/fabric_rpc.erl
parent5f8844cba7f55ed416050c2bdb8ee8a554a6f191 (diff)
reorganize rpc calls, add doc_count and update_seq
Diffstat (limited to 'src/fabric_rpc.erl')
-rw-r--r--src/fabric_rpc.erl39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index 90ee8627..fa67b13f 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -1,14 +1,40 @@
-module(fabric_rpc).
--export([get_db_info/1]).
+-export([get_db_info/1, get_doc_count/1, get_update_seq/1]).
-export([open_doc/3, open_revs/4, get_missing_revs/2, update_docs/3]).
--include("../../couch/src/couch_db.hrl").
+-include("fabric.hrl").
-include_lib("eunit/include/eunit.hrl").
+%% rpc endpoints
+%% call to with_db will supply your M:F with a #db{} and then remaining args
+
+get_db_info(DbName) ->
+ with_db(DbName, {couch_db, get_db_info, []}).
+
+get_doc_count(DbName) ->
+ rexi:reply(case couch_db:open(DbName) of
+ {ok, Db} ->
+ {ok, {Count, _DelCount}} = couch_btree:full_reduce(Db#db.id_tree),
+ {ok, Count};
+ Error ->
+ Error
+ end).
+
+get_update_seq(DbName) ->
+ rexi:reply(case couch_db:open(DbName) of
+ {ok, #db{update_seq = Seq}} ->
+ {ok, Seq};
+ Error ->
+ Error
+ end).
+
open_doc(DbName, DocId, Options) ->
with_db(DbName, {couch_db, open_doc_int, [DocId, Options]}).
+open_revs(DbName, Id, Revs, Options) ->
+ with_db(DbName, {couch_db, open_doc_revs, [Id, Revs, 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
@@ -26,15 +52,6 @@ get_missing_revs(DbName, IdRevsList) ->
Error
end).
-open_revs(DbName, Id, Revs, Options) ->
- with_db(DbName, {couch_db, open_doc_revs, [Id, Revs, Options]}).
-
-%% rpc endpoints
-%% call to with_db will supply your M:F with a #db{} and then remaining args
-
-get_db_info(DbName) ->
- with_db(DbName, {couch_db, get_db_info, []}).
-
update_docs(DbName, Docs, Options) ->
with_db(DbName, {couch_db, update_docs, [Docs, Options]}).