MongoDB C++ Driver legacy-1.0.0
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions | Variables
dbclientinterface.h File Reference

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

#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
#include "mongo/config.h"
#include "mongo/base/string_data.h"
#include "mongo/client/bulk_operation_builder.h"
#include "mongo/client/exceptions.h"
#include "mongo/client/export_macros.h"
#include "mongo/client/index_spec.h"
#include "mongo/client/write_concern.h"
#include "mongo/client/write_options.h"
#include "mongo/db/jsobj.h"
#include "mongo/logger/log_severity.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/stdx/functional.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/message.h"
#include "mongo/util/net/message_port.h"

Go to the source code of this file.

Classes

class  mongo::ConnectionString
 ConnectionString can parse MongoDB URIs with the following format: 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

namespace  mongo
 the main MongoDB namespace
 

Macros

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

Functions

MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::nsGetDB (const std::string &ns)
 
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::nsGetCollection (const std::string &ns)
 
MONGO_CLIENT_API bool MONGO_CLIENT_FUNC mongo::serverAlive (const std::string &uri)
 pings server to check if it's up
 

Variables

 QueryOption_CursorTailable = 1 << 1
 Tailable means cursor is not closed when the last data is retrieved.
 
 QueryOption_SlaveOk = 1 << 2
 allow query of replica slave.
 
 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.
 
 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.
 
 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.
 
 ReadPreference_PrimaryOnly = 0
 Read from primary only.
 
 ReadPreference_PrimaryPreferred
 Read from primary if available, otherwise a secondary.
 
 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.
 

Detailed Description

Core MongoDB C++ driver interfaces are defined here.

Macro Definition Documentation

◆ MONGO_QUERY

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

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

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

Variable Documentation

◆ QueryOption_AwaitData

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

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

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( stdx::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

QueryOption_SlaveOk = 1 << 2

allow query of replica slave.

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

◆ ReadPreference_PrimaryOnly

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

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.