title: DynamoDB Conditional Expression
body: <p>I'm working on a website right now, and I'm trying to make a conditional update request to Dynamo using the AWS SDK for Javascript However, it appears that the request is ignoring my conditional and the update occurs no matter what. I'll post the code below, but essentially what I'm trying to do is the following:</p>
  
  <ul>
  <li>If the new score is greater than the current score (in the database) update it, otherwise leave it be</li>
  </ul>
  
  <pre class="lang-js prettyprint-override"><code>// Update method
  async function updateUserStats(dynamoParams) {
  
      return await dynamodb.update(dynamoParams, function (err, data) {
          if (err) {
              console.log("err: ", err);
              return "Unable to update item. Error JSON: " + JSON.stringify(err, null, 2);
          } else {
              console.log("Woot: ", data);
              return "Successfully updated user! " + JSON.stringify(data, null, 2);
          }
      });
  }
  
  // QueryParams with DynamoDB Update request
  { 
      TableName: 'UserStats',
      Key: { 
          username: 'Talia' 
      },
      UpdateExpression: 'SET Cindy.score = :score,Cindy.dateCompleted = :dateCompleted',
      ExpressionAttributeValues: { 
          ':score': 50, 
          ':dateCompleted': '2017-12-99' 
      },
      ReturnValues: 'UPDATED_NEW',
      ConditionalExpression: 'Cindy.score &lt;= :score' 
  }
  
  // DynamoDB Table
  
  Username | Cindy
    Talia    {score: 25, dateCompleted: "2018-05-14"}
  </code></pre>