Closed nougad closed 13 years ago
You right. Fixed in last head . Now Server and Database options are merged. If an options is set in Database, its value will be use in place of the Server one.
Ex.:
1> couchbeam:start().
2> S = couchbeam:server_connection("localhost", 5984, "", [{basic_auth, {"guest", "test"}}]).
{server,"localhost",5984,false,[],
[{basic_auth,{"guest","test"}}]}
3> {ok, Db} = couchbeam:open_db(S, "testdb").
{ok,{db,{server,"localhost",5984,false,[],
[{basic_auth,{"guest","test"}}]},
"testdb",
[{basic_auth,{"guest","test"}}]}}
4> {ok, Db1} = couchbeam:open_db(S, "testdb", [{basic_auth, {"guest1", "test"}}]).
{ok,{db,{server,"localhost",5984,false,[],
[{basic_auth,{"benoitc","test"}}]},
"testdb",
[{basic_auth,{"guest1","test"}}]}}
It's also useful when you set proxy or ssl infos.
Hi, I open a new server with:
then I want the database: {ok, Db} = couchbeam:open_or_create_db(Server, "dbname").
This creates a new database with the auth options in Server. But It saves the empty Options into the #db record:
The Db record with Server and empty options:
If I try to get db_info from this DB I get an 401 because db_info uses the empty options from db-Record:
A workaround is to copy all options on every db/view manually:
But I expect couchbeam does this for me. One solution is to use always the options in server. For example:
instead of:
But perhaps it is useful sometimes to have different options in db/view. Then the options must be redundant in server and db/view. But it should copied automatically in all related methods. For example:
Instead of open_or_create_db method above. If you tell me your preferences I can make you a patch.