diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-01-15 11:38:32 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-01-15 11:38:32 -0500 |
commit | 2dcdaa494afcc99a888d41a3e1702dadddbd480e (patch) | |
tree | 3071bf283683ff774044d5be02bcaf30d1c7b537 | |
parent | db0b2adb69ee5ba41d830c0cbfd2d8a73d661c11 (diff) | |
download | mongo-2dcdaa494afcc99a888d41a3e1702dadddbd480e.tar.gz |
explicitly use mongo:: for this example for clarity
-rw-r--r-- | client/examples/first.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/client/examples/first.cpp b/client/examples/first.cpp index 0adcef4446c..76ae0bd77d8 100644 --- a/client/examples/first.cpp +++ b/client/examples/first.cpp @@ -8,11 +8,8 @@ #include "mongo/client/dbclient.h" -using namespace std; -using namespace mongo; - -void insert( DBClientConnection & conn , const char * name , int num ) { - BSONObjBuilder obj; +void insert( mongo::DBClientConnection & conn , const char * name , int num ) { + mongo::BSONObjBuilder obj; obj.append( "name" , name ); obj.append( "num" , num ); conn.insert( "test.people" , obj.doneAndDecouple() ); @@ -20,7 +17,7 @@ void insert( DBClientConnection & conn , const char * name , int num ) { int main() { - DBClientConnection conn; + mongo::DBClientConnection conn; string errmsg; if ( ! conn.connect( "127.0.0.1" , errmsg ) ) { cout << "couldn't connect : " << errmsg << endl; @@ -28,35 +25,35 @@ int main() { } { // clean up old data from any previous tests - BSONObjBuilder query; + mongo::BSONObjBuilder query; conn.remove( "test.people" , query.doneAndDecouple() ); } insert( conn , "eliot" , 15 ); insert( conn , "sara" , 23 ); - + { - BSONObjBuilder query; - auto_ptr<DBClientCursor> cursor = conn.query( "test.people" , query.doneAndDecouple() ); + mongo::BSONObjBuilder query; + auto_ptr<mongo::DBClientCursor> cursor = conn.query( "test.people" , query.doneAndDecouple() ); cout << "using cursor" << endl; while ( cursor->more() ) { - BSONObj obj = cursor->next(); + mongo::BSONObj obj = cursor->next(); cout << "\t" << obj.jsonString() << endl; } } - + { - BSONObjBuilder query; + mongo::BSONObjBuilder query; query.append( "name" , "eliot" ); - BSONObj res = conn.findOne( "test.people" , query.doneAndDecouple() ); + mongo::BSONObj res = conn.findOne( "test.people" , query.doneAndDecouple() ); cout << res.isEmpty() << "\t" << res.jsonString() << endl; } - + { - BSONObjBuilder query; + mongo::BSONObjBuilder query; query.append( "name" , "asd" ); - BSONObj res = conn.findOne( "test.people" , query.doneAndDecouple() ); + mongo::BSONObj res = conn.findOne( "test.people" , query.doneAndDecouple() ); cout << res.isEmpty() << "\t" << res.jsonString() << endl; } |