title: node.js AWS dynamodb updateItem
body: <p>Is there a way to achieve the following few points with updateItem:</p>
  <ol>
  <li>Add attributes if the attributes not exist in DynamoDB</li>
  <li>Update attributes if the attributes exist in DynamoDB</li>
  <li>Leave those attributes as what they are if the attributes are not contained in the params.</li>
  </ol>
  <p>Here is an example:
  This is the object in DynamoDB:</p>
  <pre><code>{
      id: &quot;1234&quot;,
      variable1: &quot;hello&quot;,
      variable2: &quot;world&quot;
  }
  </code></pre>
  <p>Here is the input that I wish to update:</p>
  <pre><code>{
      id: &quot;1234&quot;,
      variable1: &quot;hello2&quot;,
      variable23: &quot;dog&quot;  // the variable name &quot;variable23&quot; could be anything
  }
  </code></pre>
  <p>Here is the updated item in the DynamoDB that I want to achieve:</p>
  <pre><code>{
      id: &quot;1234&quot;,
      variable1: &quot;hello2&quot;,
      variable2: &quot;world&quot;,
      variable23: &quot;dog&quot;
  }
  </code></pre>
  <p>The &quot;variable23&quot; could be any variable name as input.</p>
  <p>I use node.js</p>