Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (26 sloc) 0.927 kB
/* simple_client_demo.cpp
See also :
How to build and run:
(1) Using the mongoclient:
g++ simple_client_demo.cpp -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options
(2) using client_lib.cpp:
g++ -I .. simple_client_demo.cpp mongo_client_lib.cpp -lboost_thread-mt -lboost_filesystem
#include <iostream>
#include "dbclient.h" // the mongo c++ driver
using namespace std;
using namespace mongo;
using namespace bson;
int main() {
cout << "connecting to localhost..." << endl;
DBClientConnection c;
cout << "connected ok" << endl;
unsigned long long count = c.count("");
cout << "count of exiting documents in collection : " << count << endl;
bo o = BSON( "hello" << "world" );
c.insert("", o);
return 0;
Jump to Line
Something went wrong with that request. Please try again.