Docs Home → MongoDB Kafka Connector
Sink Connector Write Model Strategies
On this page
This version of the documentation is archived and no longer supported. View the current documentation to learn how to upgrade your version of the MongoDB Kafka Connector.
Overview
Use the strategies in the following table to specify how the sink connector writes data into MongoDB. You can specify a write strategy with the following configuration:
writemodel.strategy=<a writemodel strategy>
For a list of sink connector configuration settings organized by category, see the guide on Sink Connector Configuration Properties.
Strategies
Name | Description | |
---|---|---|
DefaultWriteModelStrategy | Description: This strategy uses the ReplaceOneDefaultStrategy by default, and the InsertOneDefaultStrategy if you set the timeseries.timefield option.This is the default value for the writemodel.strategy configuration setting. | |
ReplaceOneDefaultStrategy | Description: Replaces at most one document in MongoDB that matches a sink record by the _id field. If no documents match, insert the sink record as a new document.Apply the following configuration to your sink connector to specify this setting:
| |
ReplaceOneBusinessKeyStrategy | Description: Replaces at most one document that matches a sink record by a specified business key. If no documents match, insert the sink record as a new document. Apply the following configuration to your sink connector to specify this setting:
To see an example showing how to use this strategy, see our guide on write model strategies. | |
DeleteOneDefaultStrategy | Description: Deletes at most one document that matches your sink connector's key structure by the _id field only when the document contains a null value structure.This is implicitly specified when you set mongodb.delete.on.null.values=true .You can set this explicitly with the following configuration:
| |
UpdateOneTimestampsStrategy | Description: Add _insertedTS (inserted timestamp) and _modifiedTS (modified timestamp) fields into documents.Apply the following configuration to your sink connector to specify this setting:
To see an example showing how to use this strategy, see our guide on write model strategies. | |
UpdateOneBusinessKeyTimestampStrategy | Description: Add _insertedTS (inserted timestamp) and _modifiedTS (modified timestamp) fields into documents that match a business key.Apply the following configuration to your sink connector to specify this setting:
|