Skip to main content

Syntax

Parameters

Data type mapping

Examples

Below are some use cases for your reference.

Sink data with append-only

To create a sink with the append-only type:
In append-only mode, MongoDB will automatically generate an _id field for each record, typically with a value of the ObjectId type. This is necessary because _id is the primary key in MongoDB.

Sink data with upsert

To create a sink with the upsert type for a table with a single key:
single key
Assuming the schema of t2 is: Given the record: The record written to MongoDB will be:
No redundant id field will exist if the primary key of t2 is _id.
compound key
The record written to MongoDB will be:

Dynamic collection name

Dynamic collection names are useful in certain scenarios. For example, a multi-tenant application may store its data using sharding, where tenant_id is included as a prefix in the collection name, such as sharding_2024_01.tenant1_order. This approach offers more flexibility and enables efficient data organization and retrieval based on specific tenant requirements. To use a dynamic collection name:
  • collection.name: Serve as a fallback collection name if the value of collection.name.field is empty or null. In this case, it defaults to demo.t2.
  • collection.name.field: Specify the field used for the collection name. This field must be of type varchar.
  • collection.name.field.drop: When set to true, it avoids duplicate values of collection.name.field in the result collection.