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:_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
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
Dynamic collection name
Dynamic collection names are useful in certain scenarios. For example, a multi-tenant application may store its data using sharding, wheretenant_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 ofcollection.name.fieldis empty or null. In this case, it defaults todemo.t2.collection.name.field: Specify the field used for the collection name. This field must be of typevarchar.collection.name.field.drop: When set totrue, it avoids duplicate values ofcollection.name.fieldin the result collection.