> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sync.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MongoDB

export const CommonDatasourceMoreInformation = ({datasource = "the data source", advancedurl = "", siteName = "CData Sync", driverVersion = ""}) => {
  return <>
      <p>
        For more information about interactions between {siteName} and {datasource}, see{' '}
        <a href={`https://cdn.cdata.com/help/${advancedurl}${driverVersion}/synch/default.htm`}>
          {datasource} Connector for {siteName}
        </a>.
      </p>
    </>;
};

export const CommonAuthSchemeNone = ({siteName = "CData Sync", siteNameShort = "Sync", datasource = "the data source"}) => {
  return <>
      <p>To connect without authentication, select <strong>None</strong> for <strong>Auth Scheme</strong>. No additional properties are required.</p>
    </>;
};

export const CommonAuthSchemePlain = ({siteName = "CData Sync", siteNameShort = "Sync", datasource = "the data source"}) => {
  return <>
      <p>To connect with a plain-text login, specify these properties:</p>
      <ul>
        <li><strong>Auth Scheme:</strong> Select <strong>Plain</strong>.</li>
        <li><strong>User:</strong> Enter the username that you use to authenticate to your {datasource} account.</li>
        <li><strong>Password:</strong> Enter the password that you use to authenticate to your {datasource} account.</li>
      </ul>
    </>;
};

export const CommonDatasourceAddConnector = ({datasource = "the data source", title = "the connector", destination = false, siteNameShort = "Sync"}) => {
  return <>
      <p>
        To enable {siteNameShort} to use data from {datasource}, you first must add the
        connector, as follows:
      </p>
      <ol>
        <li>Open the <strong>Connections</strong> page of the {siteNameShort} dashboard.</li>
        <li>Click <strong>Add Connection</strong> to open the <strong>Select Connectors</strong> page.</li>
        <li>
          Click the <strong>{destination ? "Destinations" : "Sources"}</strong> tab and locate
          the <strong>{title}</strong> row.
        </li>
        <li>
          Click the <strong>Configure Connection</strong> icon at the end of that row to open
          the <strong>New Connection</strong> page. This action opens the{' '}
          <strong>Add Connection</strong> dialog box.
          <br />
          <strong>Note:</strong> If the <strong>Configure Connection</strong> icon is not
          available, click the <strong>Download Connector</strong> icon to install
          the {title} connector.
        </li>
        <li>Enter a name for your connection in the <strong>Add Connection</strong> dialog box.</li>
        <li>Click <strong>Add</strong> to open the <strong>Settings</strong> tab for your connector.</li>
      </ol>
      <p>
        For more information about installing new connectors, see{' '}
        <a href="../connections">Connections</a>.
      </p>
    </>;
};

export const CommonDatasourceIntroDestination = ({datasource = "the data source", siteName = "CData Sync"}) => {
  return <p>
      You can use the {datasource} connector from the {siteName} application to move data
      from any supported source to the {datasource} destination. To do so, you need to add
      the connector, authenticate to the connector, and complete your connection.
    </p>;
};

export const driverVersion = "M";

export const siteNameShort = "Sync";

export const siteName = "CData Sync";

<CommonDatasourceIntroDestination datasource="MongoDB" siteName={siteName} />

## Add the MongoDB Connector

<CommonDatasourceAddConnector datasource="MongoDB" title="MongoDB" destination={true} siteNameShort={siteNameShort} />

## Authenticate to MongoDB

After you add the connector, you need to set the required properties.

* **Server:** Enter the name or address of the server on which your MongoDB instance runs. The default server is **localhost**.
* **Port:** Enter the port for the MongoDB database. The default port value is **27017**.

{siteName} supports authenticating to MongoDB in several ways. Select your authentication method below to proceed to the relevant section that contains the authentication details.

* [**MongoDB Challenge Response**](#mongodb-challenge-response)
* [**SCRAM SHA-1**](#scram-sha-1)
* [**SCRAM SHA-256**](#scram-sha-256)
* [**PLAIN**](#plain)
* [**General Security Services API**](#generic-security-services-api)
* [**X.509 Certificate**](#x509-certificate)
* [**None**](#oauth)

### MongoDB Challenge Response

To connect with a MongoDB challenge response (CR), specify the following properties:

* **Auth Scheme:** Select **MongoDB-CR**.
* **User:** Enter the username that you use to authenticate to the MongoDB account.
* **Password:** Enter the password that you use to authenticate to the MongoDB account.

### SCRAM SHA-1

To connect with the SCRAM SHA-1 credentials, specify these properties:

* **Auth Scheme:** Select **SCRAM-SHA-1**.
* **User:** Enter the username that you use to authenticate to the MongoDB account.
* **Password:** Enter the password that you use to authenticate to the MongoDB account.

### SCRAM SHA-256

To connect with the SCRAM SHA-256 credentials, specify these properties:

* **Auth Scheme:** Select **SCRAM-SHA-256**.
* **User:** Enter the username that you use to authenticate to the MongoDB account.
* **Password:** Enter the password that you use to authenticate to the MongoDB account.

### Plain

<CommonAuthSchemePlain siteName={siteName} datasource="MongoDB" />

### Generic Security Services API

To connect with Kerberos credentials, specify these properties:

* **Auth Scheme:** Select **GSSAPI**.
* **Kerberos KDC:** Enter the this to the host name or IP Address of your Kerberos Key Distribution Center (KDC) machine.
* **Kerberos Realm:** Enter the Kerberos realm that you use to authenticate to Kerberos.
* **Kerberos SPN:** Enter the service principal name (SPN) for the Kerberos domain controller.
* **Kerberos User:** Enter the principal name for the Kerberos domain controller. They syntax for this name is *Host*/*User*@realm.
* (Optional) **Kerberos Keytab File:** Enter the full file path to your Kerberos keytab file.
* (Optional) **Kerberos Ticket Cache:** Enter the full file path to an MIT Kerberos credential cache file.

### X.509 Certificate

To connect with X.509 certificate authentication, specify these properties:

* \*\*Auth Scheme:\*\*Select **X509**.
* **User:** Enter the username that you use to authenticate to the MongoDB account.
* **Password:** Enter the password that you use to authenticate to the MongoDB account.

### None

<CommonAuthSchemeNone siteName={siteName} />

## Complete Your Connection

To complete your connection:

1. Specify the following properties:
   * (Optional) **Database:** Enter the name of the MongoDB database that you want to read from and write to.

     **Note:** To connect to data from one database and authenticate to another database, you need to set both **Database** and **Auth Database**.

   * (Optional) **Auth Database:** Enter the name of the MongoDB database that you want to use for authentication. (See note above for when to specify this property.)

     **Note:** If you want to use LDAP authentication, set **Auth Database** to **\$external** and set **AuthScheme** to **PLAIN**. This **Auth Scheme** value specifies the SASL PLAIN mechanism. This mechanism transmits credentials over plaintext, so it is not suitable for use without TLS/SSL on untrusted networks.

   * (Optional) **Replica Set:** Enter a comma-separated list of secondary servers in the replica set, specified by address and port.

     **Example:** *ServerURL*\_1:27017,*ServerURL*\_2:27017

   * (Optional) **DNS Server:** Enter the hostname of a domain name system (DNS) server that can resolve the necessary DNS entries.

   * **Use SSL:** Select whether you want to enable Secure Sockets Layer (SSL). By default, the **Enable** checkbox is not selected.

2. Define advanced connection settings on the **Advanced** tab. (In most cases, though, you should not need these settings.)

   **Note:** To ensure that the UPSERT command runs correctly when you use MongoDB as a destination, you must configure the following properties in the **Miscellaneous** section of the tab:

   * **Data Model:** Select **DOCUMENT**.
   * **Flatten Arrays:** Enter a value of **0**.
   * **Flatten Objects:** Select **False**.

   In your job configuration, you also need to map the MongoDB `_id` field as the primary key for your source table.

   These settings are required because MongoDB upserts only work with unflattened documents. Flattening arrays or objects changes the structure into multiple records, which prevents MongoDB from matching rows for update. Mapping the primary key to the `_id` column ensures that {siteNameShort} can correctly identify and update existing documents instead of inserting duplicates.

3. Click **Create & Test** to create your connection.

## More Information

<CommonDatasourceMoreInformation datasource="MongoDB" advancedurl="DG" siteName={siteName} driverVersion={driverVersion} />
