TMongoConnection = class(TMongoObject)
class PASCALIMPLEMENTATION TMongoConnection : public TMongoObject
To obtain an instance of TMongoConnection, do not create one directly. Instead, configure a TFDConnection component to connect to your MongoDB server, ensure that it is connected, and cast its CliObj property to TMongoConnection:
FDConnection1.Connected := True; MyConnection := TMongoConnection(FDConnection1.CliObj);
FDConnection1->Connected = true; TMongoConnection* MyConnection = (TMongoConnection*) FDConnection1->CliObj;
Use the following members to access data from the MongoDB server:
- Collections to get a shared instance of TMongoCollection, or GetCollection to get a new instance.
- Databases to get a shared instance of TMongoDatabase, or GetDatabase to get a new instance.
- Dereference, to obtain a document from the MongoDB server given its DBRef.
- ListDatabases, to obtain a list of the databases in the MongoDB server.
TMongoConnection provides several members to obtain information about the MongoDB server:
- ServerVersion is the version of the MongoDB server.
- URI is the URI of the MongoDB server.
- GetServerStatus returns a document that provides an overview of the state of the database process.
- Ping raises an exception if the MongoDB server does not respond to commands.
- max_bson_size is the maximum size that a document stored in a MongoDB server may have.
- max_message_size is the maximum size that a request that you send to the MongoDB server may have.
To run database commands, use any of the following methods:
- Command runs the specified command and returns a cursor to access all result documents.
- CommandSimple runs the specified command and returns a document that contains the response from the server.
To configure the replica set read and write semantics of the MongoDB server use the following properties:
Use SSLInit to configure the SSL options of your client for secured communications with your MongoDB server.