mongodb c++ driver authenticate

Friday, July 4, 2014

I use ScopedDbConnection, it made in each db operation. If I do:



mongo::ScopedDbConnection conn(host);
conn->auth(BSON("user"<<"user1"<<"pwd"<<"password1"));
...
conn.done();


That means there will involve auth process in every db operation, this is unnecessary. In java driver, there is DB class which has a authenticate function, after "db.authenticate(...)", all subsequent operation can be execute rather than auth on each db connection like above code.


Is there way to just auth once in C++ driver?







http://ift.tt/1qxa8Oj