summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2018-10-25 16:09:38 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2019-01-18 13:03:28 -0600
commit24a36985498035e586a81ac8fd5035e5e1e98f07 (patch)
treebf57070d91d1e2b9abe0dbec980ac48409e046b5
parent5d219dd79d86d41fec21fe666d9308dd26c2efae (diff)
downloadcouchdb-24a36985498035e586a81ac8fd5035e5e1e98f07.tar.gz
Improve `couch_db:clustered_db` flexibility
This allows for setting any combintaion of supported settings using a proplist appraoch.
-rw-r--r--src/couch/src/couch_db.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 9bc0f9263..2b4f21aec 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -185,11 +185,22 @@ reopen(#db{} = Db) ->
incref(#db{} = Db) ->
couch_db_engine:incref(Db).
-clustered_db(DbName, UserCtx) ->
- clustered_db(DbName, UserCtx, []).
+clustered_db(DbName, Options) when is_list(Options) ->
+ UserCtx = couch_util:get_value(user_ctx, Options, #user_ctx{}),
+ SecProps = couch_util:get_value(security, Options, []),
+ Props = couch_util:get_value(props, Options, []),
+ {ok, #db{
+ name = DbName,
+ user_ctx = UserCtx,
+ security = SecProps,
+ options = [{props, Props}]
+ }};
+
+clustered_db(DbName, #user_ctx{} = UserCtx) ->
+ clustered_db(DbName, [{user_ctx, UserCtx}]).
clustered_db(DbName, UserCtx, SecProps) ->
- {ok, #db{name = DbName, user_ctx = UserCtx, security = SecProps}}.
+ clustered_db(DbName, [{user_ctx, UserCtx}, {security, SecProps}]).
is_db(#db{}) ->
true;