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 MongoDB source endpoint, take the following steps:
-
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.
-
-
Configure the connection:
Custom installation
-
Under Host, click + Host and enter the domain name (FQDN) or IP address of the host.
-
In Replica set, enter the replica set ID.
-
In Port, enter the port to connect with.
-
To encrypt data transmission, upload a
.pem
file with the certificate (public key) under CA Certificate. -
In Authentication source, enter the name of the database associated with the user and password.
-
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 withmongodb+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 is27018
for non-sharded clusters and27017
for sharded ones. -
<database>
: Name of the database to connect to.
SRV
-
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.
-
In Replica set, enter the replica set ID.
-
To encrypt data transmission, upload a
.pem
file with the certificate (public key) under CA Certificate. -
In Authentication source, enter the name of the database associated with the user and password.
-
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.
-
-
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:
-
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.
-
-
Configure the connection:
Custom installation
-
Under Host, click + Host and enter the domain name (FQDN) or IP address of the host.
-
In Replica set, enter the replica set ID.
-
In Port, enter the port to connect with.
-
To encrypt data transmission, upload a
.pem
file with the certificate (public key) under CA Certificate. -
In Authentication source, enter the name of the database associated with the user and password.
-
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 withmongodb+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 is27018
for non-sharded clusters and27017
for sharded ones. -
<database>
: Name of the database to connect to.
SRV
-
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.
-
In Replica set, enter the replica set ID.
-
To encrypt data transmission, upload a
.pem
file with the certificate (public key) under CA Certificate. -
In Authentication source, enter the name of the database associated with the user and password.
-
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.
-
In Authentication source, enter the name of the database associated with the user and password.
-
In User and Password, enter the user credentials to connect to the database.
-
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.
-
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()
-
-
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 |