FireDAC.Phys.MongoDBWrapper.TMongoConnection

From RAD Studio API Documentation
Jump to: navigation, search

FireDAC.Phys.MongoDBWrapper.TMongoObjectSystem.TObjectTMongoConnection

Delphi

TMongoConnection = class(TMongoObject)

C++

class PASCALIMPLEMENTATION TMongoConnection : public TMongoObject

Properties

Type Visibility Source Unit Parent
class public
FireDAC.Phys.MongoDBWrapper.pas
FireDAC.Phys.MongoDBWrapper.hpp
FireDAC.Phys.MongoDBWrapper FireDAC.Phys.MongoDBWrapper

Description

Represents a connection to a MongoDB server, and provides access to its databases and collections.

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:

Delphi:

FDConnection1.Connected := True;
MyConnection := TMongoConnection(FDConnection1.CliObj);

C++:

FDConnection1->Connected = true;
TMongoConnection* MyConnection = (TMongoConnection*) FDConnection1->CliObj;

The connection that TMongoConnection represents is open by default. Use Open to change the target MongoDB server of your connection, or Close to close the connection.

Use the following members to access data from 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.

TMongoConnection encapsulates a mongoc_client_t MongoDB structure.