title: DynamoDB conditional update using nodejs
body: <p>how do i conditional update item in dynamoDB using nodejs?  If exists, just do an increment alone - it is working as expected. But I am struggling in, when the item is not exists, need to add it and next iteration onwards do increment. got this error "<strong><em>The provided expression refers to an attribute that does not exist in the item</em></strong>".</p>
  
  <pre><code>function increment(data, cb) {
      const opt = {
          Key: {
              id: {S: id},
              dateKey: {S: data.dateVal}
          },
          ExpressionAttributeValues: {
              ':counter': {N: '' + 1},
              ':val1': {S: data.val1},
              ':val2': {S: data.val2}
          },
          UpdateExpression: 'SET counter=counter+:counter, val1=:val1, val2=:val2',ReturnValues: 'UPDATED_NEW',
          TableName:tableName
      };
  
      db.updateItem(opt, (err, data) =&gt; {
          if (err)
              return cb(err);
  
          const counter = getCounter(data.Attributes); //private method
          return cb(null, counter);
      });
  }
  </code></pre>