diff options
-rw-r--r-- | client/model.cpp | 7 | ||||
-rw-r--r-- | client/model.h | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/client/model.cpp b/client/model.cpp index dd7049e7fa3..f8a5e596f40 100644 --- a/client/model.cpp +++ b/client/model.cpp @@ -18,11 +18,16 @@ #include "stdafx.h" #include "model.h" +#include "connpool.h" namespace mongo { bool Model::load(BSONObj& query) { - BSONObj b = conn()->findOne(getNS(), query); + ScopedDbConnection scoped( modelServer() ); + DBClientWithCommands& conn = scoped.conn(); + BSONObj b = conn.findOne(getNS(), query); + scoped.done(); + if ( b.isEmpty() ) return false; diff --git a/client/model.h b/client/model.h index 049393a010c..b46deb01855 100644 --- a/client/model.h +++ b/client/model.h @@ -43,12 +43,12 @@ namespace mongo { virtual void unserialize(BSONObj& from) = 0; /** Define this as you see fit if you are using the default conn() implementation. */ - static DBClientWithCommands *globalConn; + static string defaultServer; /** Override this if you need to do fancier connection management than simply using globalConn. */ - virtual DBClientWithCommands* conn(){ - uassert( "globalConn not set" , globalConn ); - return globalConn; + virtual string modelServer(){ + uassert( "defaultServer not set" , defaultServer.size() ); + return defaultServer; } /** Load a single object. |