diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2018-10-25 16:09:38 -0500 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-01-03 15:47:36 -0600 |
commit | 8f5d0fdeae244b8796a0e98cbc2f445c26298af7 (patch) | |
tree | 8a2596c12761a5aa8a4cb28f6af444edb743a13f | |
parent | 3d6247e462023bf15d855ddebaa333c2141ce157 (diff) | |
download | couchdb-8f5d0fdeae244b8796a0e98cbc2f445c26298af7.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.erl | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl index 4b41dc918..50b0e779d 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; |