Add support for Template Writes

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Unknown
    • 3.0.0
    • Affects Version/s: None
    • Component/s: Sink
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
              Reporter:
              Ross Lawley
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated: