vibe.db.mongo.connection

Low level mongodb protocol.

Types 12

aliasMongoErrorDescription = immutable(_MongoErrorDescription)

D POD representation of Mongo error object.

For successful queries "code" is negative. Can be used also to check how many documents where updated upon a successful query via "n" field.

classMongoException : Exception

Root class for vibe.d Mongo driver exception hierarchy.

Constructors
this(string message, string file = __FILE__, size_t line = __LINE__, Throwable next = null)

Generic class for all exception related to unhandled driver problems.

I.e.: protocol mismatch or unexpected mongo service behavior.

Constructors
this(string message, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
deprecated Check for MongoException instead - the modern write commands now throw MongoBulkWriteException on error

Wrapper class for all inner mongo collection manipulation errors.

It does not indicate problem with vibe.d driver itself. Most frequently this one is thrown when MongoConnection is in checked mode and getLastError() has something interesting.

Fields
Methods
int code() @property @safe const nothrow
int connectionId() @property @safe const nothrow
int n() @property @safe const nothrow
double ok() @property @safe const nothrow
Constructors
this(MongoErrorDescription description, string file = __FILE__, size_t line = __LINE__, Throwable next = null)

Generic class for all exceptions related to authentication problems.

I.e.: unsupported mechanisms or wrong credentials.

Constructors
this(string message, string file = __FILE__, size_t line = __LINE__, Throwable next = null)

[internal] Provides low-level mongodb protocol access.

It is not intended for direct usage. Please use vibe.db.mongo.db and vibe.db.mongo.collection modules for your code. Note that a MongoConnection may only be used from one fiber/thread at a time.

Fields
ushort defaultPort
Methods
void connectToHost(MongoHost host, bool doAuthenticate = true) @safe
void disconnect() @safe
bool connected() @property @safe const
bool alive() @property @safeChecks if the connection is alive by probing the socket for remote close.
const(ServerDescription) description() @property @safe const
void update(string collection_name, UpdateFlags flags, Bson selector, Bson update) @safe
void insert(string collection_name, InsertFlags flags, Bson[] documents) @safe
void query(T)(string collection_name, QueryFlags flags, int nskip, int nret, Bson query, Bson returnFieldSelector, scope ReplyDelegate on_msg, scope DocDelegate!T on_doc) @safe
Bson runCommand(T, CommandFailException = MongoDriverException)( string database, Bson command, string errorInfo = __FUNCTION__, string errorFile = __FILE__, size_t errorLine = __LINE__ ) @safeRuns the given Bson command (Bson object with the first entry in the map being the command name) on the given database.
Bson runCommandUnchecked(T, CommandFailException = MongoDriverException)( string database, Bson command, string errorInfo = __FUNCTION__, string errorFile = __FILE__, size_t errorLine = __LINE__ ) @safe
void startFind(T)(Bson command, scope GetMoreHeaderDelegate on_header, scope GetMoreDocumentDelegate!T on_doc, string batchKey = "firstBatch", string errorInfo = __FUNCTION__, string errorFile = __FILE__, size_t errorLine = __LINE__) @safeForwards the `find` command passed in to the database, handles the callbacks like with getMore. This exists for easier integration with MongoCursor!T.
void delete_(string collection_name, DeleteFlags flags, Bson selector) @safe
void killCursors(scope long[] cursors) @safe
void killCursors(string collection, scope long[] cursors) @safe
auto listDatabases() @safeQueries the server for all databases.
Constructors
this(string server, ushort port = defaultPort)Simplified constructor overload, with no m_settings
Nested Templates
getMore(T)
aliasGetMoreHeaderDelegate = void delegate(long id, string ns, size_t count) @safe
aliasGetMoreDocumentDelegate(T) = void delegate(ref T document) @safe
Fields
string name
double sizeOnDisk
bool empty
Fields
BsonObjectID processId
long counter
Fields
string address
string error
float roundTripTime
LastWrite lastWrite
Nullable!BsonObjectID opTime
ServerType type
int minWireVersion
string me
string[] hosts
string[string] tags
string setName
Nullable!int setVersion
Nullable!BsonObjectID electionId
string primary
Nullable!TopologyVersion topologyVersion
bool secondaryDeprecated since MongoDB 5.0: the `isMaster` command was replaced by `hello`. The `secondary` field itself is still present in the `hello` response.
bool ismasterDeprecated since MongoDB 5.0: renamed to `isWritablePrimary` in the `hello` command response. True if the instance is a primary, mongos, or standalone mongod.
bool isWritablePrimary
bool arbiterOnly
string msg
Nullable!int logicalSessionTimeoutMinutes
string[] compression
long lastUpdateTimeUsecsSet by the driver after probing, not deserialized from the server response.
Methods
bool satisfiesVersion(WireVersion wireVersion) @optional @safe const @nogc pure nothrow
bool isPrimary() @optional @safe const @nogc pure nothrow
bool isSecondaryNode() @optional @safe const @nogc pure nothrow
bool isReplicaSetMember() @optional @safe const @nogc pure nothrow
ServerType classifiedType() @optional @safe const @nogc pure nothrow
Nested Templates
ServerType
LastWrite
enumWireVersion : int
old = 0
v26 = 1
v26_2 = 2
v30 = 3
v32 = 4
v34 = 5
v36 = 6
v40 = 7
v42 = 8
v44 = 9
v49 = 12
v50 = 13
v51 = 14
v52 = 15
v53 = 16
v60 = 17
v61 = 18
v62 = 19
v70 = 21
v71 = 22
v72 = 23
v73 = 24
v80 = 25

Functions 2

fnbool matchesReplicaSet(string expectedSet, ref const ServerDescription desc) @safe @nogc pure nothrowChecks whether the server's replica set name matches the expected one. Returns true if no replica set is configured (empty string) or if the names match.
fnServerDescription probeServer(MongoClientSettings settings, MongoHost host) @safeProbes a MongoDB host by performing a hello handshake without authentication.

Templates 1

tmplDocDelegate(T)