Uploaded image for project: 'Kafka Connector'
  1. Kafka Connector
  2. KAFKA-321

Add support for Template Writes

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.0.0
    • Affects Version/s: None
    • Component/s: Sink
    • None

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: