MongoDB
The MongoDB destination writes data to MongoDB. For information about supported versions, see Supported Systems and Versions in the Data Collector documentation.
To write data, the MongoDB destination requires records to include a CRUD operation record header attribute. The CRUD operation header attribute indicates the operation to perform for each record. You can also enable upserts for Update and Replace records. For information about Data Collector change data processing and a list of CDC-enabled origins, see Processing Changed Data.
When you configure the MongoDB destination, you define connection information, such as the connection string and MongoDB credentials. You can also use a connection to configure the destination. You configure the database, and collection, and write concern to use.
To replace and update records, you must specify a unique key field and can optionally enable an upsert flag. When you do not specify a unique key field, replace and update records are sent to the stage for error handling.
You can optionally configure advanced options that determine how the destination connects to MongoDB, including enabling SSL/TLS for the destination.
Credentials
Based on the authentication used by the MongoDB server, configure the stage to use no authentication, username/password authentication, or LDAP authentication. When using username/password authentication, you can also use delegated authentication. When using LDAP authentication, you can use server-driven authentication or plain authentication.
By default, the destination uses no authentication.
- Connection string
- Enter credentials in the connection string on the MongoDB tab.
- Credentials tab
- Select either the Username/Password or LDAP authentication type on the Credentials tab. When using LDAP authentication, you also choose between server-driven or plain authentication.
Define the CRUD Operation
To write to MongoDB, ensure that the CRUD operation record header attribute is defined for each record earlier in the pipeline. Records without an operation record header attribute are sent to error.
To update and replace records, you must specify a unique key field. You can also enable upserts for update and replace records.
Note that when performing a DELETE operation, the destination deletes a maximum of one matching document in MongoDB. It does not delete all matching documents, as is sometimes possible with MongoDB.
- sdc.operation.type
- The MongoDB destination uses the CRUD operation in the
sdc.operation.type
record header attribute when writing to MongoDB. The MongoDB destination supports the following values for thesdc.operation.type
attribute:- 1 for INSERT
- 2 for DELETE
- 3 for UPDATE
- 7 for REPLACE
Performing Upserts
You can configure the destination to perform upserts. When you enable upserts, the destination inserts records for Update and Replace records when it does not find an existing record to update or replace.
By default, the destination does not perform upserts. If the destination does not find an existing record for a record flagged for update or replace, it does not write the record to MongoDB.
For more information about MongoDB operations and the upsert flag, see the MongoDB documentation.
Enabling SSL/TLS
You can enable the MongoDB destination to use SSL/TLS to connect to MongoDB.