David Villasmil
David Villasmil

Reputation: 415

mongodb scopeddbconnection with c++

I'm positive I'm getting al this wrong, but here's my question:

I need a connection pool to mongo which I create like so:

mongo::ScopedDbConnection connectionPool("localhost");

Then on each thread, I do:

mongo::DBClientConnection c(connectionPool.get());   <-- is this even right?

Next I need to run

c.runCommand()

and give the connection back:

connectionPool.done();

Am I doing this correctly?

Thanks all for your help!

Upvotes: 2

Views: 449

Answers (1)

David Villasmil
David Villasmil

Reputation: 415

I got it works like this:

mongo::ScopedDbConnection* c;
c = mongo::ScopedDbConnection::getScopedDbConnection("127.0.0.1");
if( c->ok() )
{
  c->get()->runCommand( "tracer", query_upsert_document, objError );
  c->done();
}

Thanks all for your help!

Regards,

Upvotes: 1

Related Questions