MongoDB connector

You can use the MongoDB connector in both source and target endpoints. In source endpoints, the connector retrieves data from MongoDB databases. In target endpoints, it inserts data to MongoDB databases.

Source endpoint

To configure a source MongoDB endpoint, take the following steps:

  1. In Connection type, select whether you want to connect to MongoDB with the standard connection (Custom installation) or with SRV.

    • Custom installation uses the standard connection method, and you need to specify all hosts and ports.

    • SRV provides a simplified way to connect to MongoDB clusters, in particular those on MongoDB Atlas.

  2. Configure the connection:

    Custom installation
    1. Under Host, click + Host and enter the domain name (FQDN) or IP address of the host.

    2. In Replica set, enter the replica set ID.

    3. In Port, enter the port to connect with.

    4. To encrypt data transmission, upload a .pem file with the certificate (public key) under CA Certificate.

    5. In Authentication source, enter the name of the database associated with the user and password.

    6. In User and Password, enter the user credentials to connect to the database.

    Standard MongoDB connection string reference

    Typically, a MongoDB connection string looks as follows:

    mongodb://<username>:<password>@<hostname>:<port>/<database>
    
    • mongodb://: Standard MongoDB protocol. If your connection string starts with mongodb+srv://, use the SRV connection type instead.

    • <username>:<password>: (Optional) Authentication credentials.

    • <hostname>: IP-address or the domain name (FQDN) of the MongoDB server.

    • <port>: Port. Default is 27018 for non-sharded clusters and 27017 for sharded ones.

    • <database>: Name of the database to connect to.

    SRV
    1. Under Hostname, enter the domain name (FQDN) or IP address of the host.

      When you use the SRV connection format, you don’t need to specify the port.

    2. In Replica set, enter the replica set ID.

    3. To encrypt data transmission, upload a .pem file with the certificate (public key) under CA Certificate.

    4. In Authentication source, enter the name of the database associated with the user and password.

    5. In User and Password, enter the user credentials to connect to the database.

    SRV connection string reference
    mongodb+srv://<username>:<password>@<hostname>/<database>
    
    • mongodb+srv://: Prefix for the SRV connection format.

    • <username>:<password>: (Optional) Authentication credentials.

    • <hostname>: IP-address or the domain name (FQDN) of the MongoDB server.

    • <database>: Name of the database to connect to.

  3. Under Collection filter, specify collections and tables you want to include or exclude:

    • Included collections: Transfer will transfer data only from these collections.

    • Excluded collections: Data from these collections won’t be transferred.

To create a MongoDB source endpoint with the API, use the endpoint.MongoSource model.

MongoDB type Transfer type
[int64](*int64)
[int32](*int32)
[int16](*int16)
[int8](*int8)
[uint64](*uint64)
[uint32](*uint32)
[uint16](*uint16)
[uint8](*uint8)
[float](*float)
[double](*double)
[string](*string)
bson [utf8](*utf8)
[boolean](*bool)
[date](*date)
[datetime](*datetime)
[timestamp](*timestamp)
bson any

Target endpoint

To configure a target MongoDB endpoint, take the following steps:

  1. In Connection type, select whether you want to connect to MongoDB with the standard connection (Custom installation) or with SRV.

    • Custom installation uses the standard connection method, and you need to specify all hosts and ports.

    • SRV provides a simplified way to connect to MongoDB clusters, in particular those on MongoDB Atlas.

  2. Configure the connection:

    Custom installation
    1. Under Host, click + Host and enter the domain name (FQDN) or IP address of the host.

    2. In Replica set, enter the replica set ID.

    3. In Port, enter the port to connect with.

    4. To encrypt data transmission, upload a .pem file with the certificate (public key) under CA Certificate.

    5. In Authentication source, enter the name of the database associated with the user and password.

    6. In User and Password, enter the user credentials to connect to the database.

    Standard MongoDB connection string reference

    Typically, a MongoDB connection string looks as follows:

    mongodb://<username>:<password>@<hostname>:<port>/<database>
    
    • mongodb://: Standard MongoDB protocol. If your connection string starts with mongodb+srv://, use the SRV connection type instead.

    • <username>:<password>: (Optional) Authentication credentials.

    • <hostname>: IP-address or the domain name (FQDN) of the MongoDB server.

    • <port>: Port. Default is 27018 for non-sharded clusters and 27017 for sharded ones.

    • <database>: Name of the database to connect to.

    SRV
    1. Under Hostname, enter the domain name (FQDN) or IP address of the host.

      When you use the SRV connection format, you don’t need to specify the port.

    2. In Replica set, enter the replica set ID.

    3. To encrypt data transmission, upload a .pem file with the certificate (public key) under CA Certificate.

    4. In Authentication source, enter the name of the database associated with the user and password.

    5. In User and Password, enter the user credentials to connect to the database.

    SRV connection string reference
    mongodb+srv://<username>:<password>@<hostname>/<database>
    
    • mongodb+srv://: Prefix for the SRV connection format.

    • <username>:<password>: (Optional) Authentication credentials.

    • <hostname>: IP-address or the domain name (FQDN) of the MongoDB server.

    • <database>: Name of the database to connect to.

    1. In Authentication source, enter the name of the database associated with the user and password.

    2. In User and Password, enter the user credentials to connect to the database.

    3. In Database name, enter the name of the database where you want to transfer your data.

      Warning

      If you don’t specify a database name, the collections will be created in databases with the same names as in the source.

    4. Select a Cleanup policy to specify how data in the target database is cleaned up when a transfer is activated, reactivated, or reloaded.

      Cleanup policy reference
      • Disabled: Don’t clean. Select this option if you only perform replication without copying data.

      • Drop (default): Fully delete the tables included in the transfer. Use this option to always transfer the latest version of the table schema to the target database from the source.

      • Truncate: Execute the remove() command for the target table each time you run a transfer.

To create a MongoDB target endpoint with the API, use the endpoint.MongoTarget model.

Transfer type MongoDB type
int64 bson
int32 bson
int16 bson
int8 bson
uint64 bson
uint32 bson
uint16 bson
uint8bson
float bson
double bson
string bson
utf8 bson
boolean bson
date bson
datetime bson
timestamp bson
any bson

See also

Previous