Consider adding flexibility to write models by providing a template based solution.
Example configuration:
writemodel.strategy = TemplateBasedWriteModelStrategy writemodel.template.model = UpdateOne writemodel.template.options.upsert = true writemodel.template.query = "{'_id': '${v._id}'}" writemodel.template.update = "{'$set': {'b': '${k.b}', '$addToSet': {'a': '${v.a}'}}"
SinkRecord:
key: {a: 1, b: 2}
value: {_id: 1, a: 'alpha'}
Write Model:
UpdateOne({_id: 1}, {$set: {b: 2}, $addToSet: {a: 'alpha'}}, new UpdateOneOptions().upsert(true))
The logic would be to handle special fields that contain a templated value eg: ${v._id} would be the _id field from the value document in the Sink Record. ${k.b} would be the b field from the key document in the Sink Record.