Update with option upsert=false

XMLWordPrintableJSON

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

      Hi,
      I need to use option upsert=false when updating a document.
      I saw in the source code that this option is hard coded to true.

      I also saw on GitHub a discussion and a related Pull Request from 2024 that is still opened:

      This is exactly what I need !

       

      More details about my use case:

      A message with type 'create' is produced on the topic:
      {{{}}
      {{  "data": {
          "type:create":

      {       "_id": <uuid_1>,       "field1": "value1",       "field2": "value2"     }

        }}}
      }
       
      I transform it and write a new document in the collection.
      {{

      {    "_id": <uuid_1>,    "field1": "value1",    "field2": "value2" }

      }}

      Then, a message with type 'update' is produced on the topic. This message contains the _id of the data to update, and only fields that are concerned by the change:

      {{{}}
      {{  "data": {
          "type:update":

      {       "_id": <uuid_1>,       "field1": "new_value1"     }

        }}}
      }

      I transform it and use the UpdateOneDefaultStrategy to update the corresponding document. It is OK in this case.

      But, I also have the case where the initial document is not in the collection (because the 'create' message has been sent in the past and my system didn't get it).
      In that case, when the 'update' message comes, a new document is created with only partial data. This is the behavior with upsert=true.
      But I need to update the document only if it exists in the collection (upsert=false) to avoid having to deal with partial documents.

            Assignee:
            Unassigned
            Reporter:
            Nicolas Moteau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: