summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-02-08 14:35:34 -0500
committerEliot Horowitz <eliot@10gen.com>2009-02-08 14:35:34 -0500
commitc154c784692bc4a3c65152fb3d761c66cfd25e63 (patch)
treecc67e5b949f6a37e65a1a5c4df64ef54e4546657
parent1d26ef15cea31d33d955dc2db8166380d792537c (diff)
downloadmongo-c154c784692bc4a3c65152fb3d761c66cfd25e63.tar.gz
Model needs a server name, not a connection, and uses pools
-rw-r--r--client/model.cpp7
-rw-r--r--client/model.h8
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.