MongoDB  2.7.0
Classes | Namespaces | Macros | Functions | Variables
dbclientinterface.h File Reference

Core MongoDB C++ driver interfaces are defined here. More...

#include "mongo/pch.h"
#include <boost/function.hpp>
#include "mongo/base/string_data.h"
#include "mongo/client/export_macros.h"
#include "mongo/db/jsobj.h"
#include "mongo/logger/log_severity.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/util/net/message.h"
#include "mongo/util/net/message_port.h"
#include "mongo/client/dbclientcursor.h"

Go to the source code of this file.

Classes

class  mongo::ConnectionString
 ConnectionString handles parsing different ways to connect to mongo and determining method samples: server server:port foo/server:port,server:port SET server,server,server SYNC Warning - you usually don't want "SYNC", it's used for some special things such as sharding config servers. More...
 
class  mongo::ConnectionString::ConnectionHook
 
class  mongo::Query
 Represents a Mongo query expression. More...
 
class  mongo::QuerySpec
 Represents a full query description, including all options required for the query to be passed on to other hosts. More...
 
class  mongo::DBConnector
 interface that handles communication with the db More...
 
class  mongo::DBClientInterface
 The interface that any db connection should implement. More...
 
class  mongo::DBClientWithCommands
 DB "commands" Basically just invocations of connection. More...
 
struct  mongo::DBClientWithCommands::MROutput
 This implicitly converts from char*, string, and BSONObj to be an argument to mapreduce You shouldn't need to explicitly construct this. More...
 
class  mongo::DBClientBase
 abstract class that implements the core db operations More...
 
class  mongo::ConnectException
 
class  mongo::DBClientConnection
 A basic connection to the database. More...
 

Namespaces

 mongo
 tools for working in parallel/sharded/clustered environment
 

Macros

#define QUERY(x)   ::mongo::Query( BSON(x) )
 Typically one uses the QUERY(...) macro to construct a Query object. More...
 

Functions

string mongo::nsGetDB (const string &ns)
 
string mongo::nsGetCollection (const string &ns)
 
bool mongo::serverAlive (const string &uri)
 pings server to check if it's up
 
DBClientBase * mongo::createDirectClient ()
 
BSONElement mongo::getErrField (const BSONObj &o)
 
bool mongo::hasErrField (const BSONObj &o)
 
MONGO_CLIENT_API std::ostream & mongo::operator<< (std::ostream &s, const Query &q)
 

Variables

 QueryOption_CursorTailable = 1 << 1
 Tailable means cursor is not closed when the last data is retrieved. More...
 
 QueryOption_SlaveOk = 1 << 2
 allow query of replica slave. More...
 
 QueryOption_OplogReplay = 1 << 3
 
 QueryOption_NoCursorTimeout = 1 << 4
 The server normally times out idle cursors after an inactivity period to prevent excess memory uses Set this option to prevent that.
 
 QueryOption_AwaitData = 1 << 5
 Use with QueryOption_CursorTailable. More...
 
 QueryOption_Exhaust = 1 << 6
 Stream the data down full blast in multiple "more" packages, on the assumption that the client will fully read all data queried. More...
 
 QueryOption_PartialResults = 1 << 7
 When sharded, this means its ok to return partial results Usually we will fail a query if all required shards aren't up If this is set, it'll be a partial result set.
 
 UpdateOption_Upsert = 1 << 0
 Upsert - that is, insert the item if no matching item is found. More...
 
 UpdateOption_Multi = 1 << 1
 Update multiple documents (if multiple documents match query expression). More...
 
 RemoveOption_JustOne = 1 << 0
 only delete one option
 
 Reserved_InsertOption_ContinueOnError = 1 << 0
 
 ReadPreference_PrimaryOnly = 0
 Read from primary only. More...
 
 ReadPreference_PrimaryPreferred
 Read from primary if available, otherwise a secondary. More...
 
 ReadPreference_SecondaryOnly
 Read from secondary if available, otherwise error.
 
 ReadPreference_SecondaryPreferred
 Read from a secondary if available, otherwise read from the primary.
 
 ReadPreference_Nearest
 Read from any member.
 
class MONGO_CLIENT_API mongo::DBClientBase
 
class MONGO_CLIENT_API mongo::DBClientConnection
 
 W_NONE = 0
 

Detailed Description

Core MongoDB C++ driver interfaces are defined here.

Macro Definition Documentation

#define QUERY (   x)    ::mongo::Query( BSON(x) )

Typically one uses the QUERY(...) macro to construct a Query object.

Example: QUERY( "age" << 33 << "school" << "UCLA" )

Variable Documentation

QueryOption_AwaitData = 1 << 5

Use with QueryOption_CursorTailable.

If we are at the end of the data, block for a while rather than returning no data. After a timeout period, we do return as normal.

QueryOption_CursorTailable = 1 << 1

Tailable means cursor is not closed when the last data is retrieved.

rather, the cursor marks the final object's position. you can resume using the cursor later, from where it was located, if more data were received. Set on dbQuery and dbGetMore.

like any "latent cursor", the cursor may become invalid at some point – for example if that final object it references were deleted. Thus, you should be prepared to requery if you get back ResultFlag_CursorNotFound.

QueryOption_Exhaust = 1 << 6

Stream the data down full blast in multiple "more" packages, on the assumption that the client will fully read all data queried.

Faster when you are pulling a lot of data and know you want to pull it all down. Note: it is not allowed to not read all the data unless you close the connection.

Use the query( boost::function<void(const BSONObj&)> f, ... ) version of the connection's query() method, and it will take care of all the details for you.

QueryOption_SlaveOk = 1 << 2

allow query of replica slave.

normally these return an error except for namespace "local".

ReadPreference_PrimaryOnly = 0

Read from primary only.

All operations produce an error (throw an exception where applicable) if primary is unavailable. Cannot be combined with tags.

ReadPreference_PrimaryPreferred

Read from primary if available, otherwise a secondary.

Tags will only be applied in the event that the primary is unavailable and a secondary is read from. In this event only secondaries matching the tags provided would be read from.

UpdateOption_Multi = 1 << 1

Update multiple documents (if multiple documents match query expression).

(Default is update a single document and stop.)

UpdateOption_Upsert = 1 << 0

Upsert - that is, insert the item if no matching item is found.