Jacobian
Jacobian

Reputation: 10812

How to drop mongodb collection using C++?

I'm asking this trivial question, because there are absolutely no tutorials and zero examples on the Web. The only thing that exists - is a C++ driver. In the source code of the driver I see a method called dropCollection, and it is defined like this:

virtual bool dropCollection (const string &ns, BSONObj *info=NULL)

But unfortunately, documentation does not shed any light on how to use this method. Intuitively, I thought that one of its arguments should be a collection name, but here I see only the strange argument &ns (I guess namespace) - what it means - I do not know.

Upvotes: 0

Views: 395

Answers (1)

chridam
chridam

Reputation: 103375

From this thread, you can use dropCollection(std::string ns) as in the following example:

mongo::DBClientConnection c;
c.connect("localhost");
//perform inserts, updates
c.dropCollection("databaseName.collectionName");

Upvotes: 1

Related Questions