summaryrefslogtreecommitdiff
path: root/src/fabric.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-07-12 12:36:54 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-07-12 12:36:54 -0400
commitab01f6fc3c50279953838d675067083a8cf0799f (patch)
treeba2d716039896d7d29ca6431f76382196494041c /src/fabric.erl
parentdc4f15e586112742cf54628e937e0f776022c953 (diff)
fix fabric:all_dbs when used with a prefix
Diffstat (limited to 'src/fabric.erl')
-rw-r--r--src/fabric.erl19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/fabric.erl b/src/fabric.erl
index 892673a5..9158b9e9 100644
--- a/src/fabric.erl
+++ b/src/fabric.erl
@@ -23,10 +23,21 @@
% db operations
all_dbs() ->
- fabric_all_databases:all_databases("").
-
-all_dbs(Customer) ->
- fabric_all_databases:all_databases(Customer).
+ all_dbs(<<>>).
+
+all_dbs(Prefix) when is_list(Prefix) ->
+ all_dbs(list_to_binary(Prefix));
+all_dbs(Prefix) when is_binary(Prefix) ->
+ Length = byte_size(Prefix),
+ MatchingDbs = ets:foldl(fun(#shard{dbname=DbName}, Acc) ->
+ case DbName of
+ <<Prefix:Length/binary, _/binary>> ->
+ [DbName | Acc];
+ _ ->
+ Acc
+ end
+ end, [], partitions),
+ {ok, lists:usort(MatchingDbs)}.
get_db_info(DbName) ->
fabric_db_info:go(dbname(DbName)).