title: Dynamodb - Insert duplication check
body: <p>I am using ConditionExpression to prevent inserting into a table if PhoneId=123 is exist in the table.  However this don't seem to work as I am geting duplicated rows.</p>
  
  <p>Note: PhoneId is not a primary key.  I have created PhoneIdIndex index, not sure how can I use that for ConditionExpression. </p>
  
  <pre><code>  return new Promise(function(resolve, reject) {
      var params = {
        TableName: "Phone",
        ReturnConsumedCapacity: "TOTAL",
        ConditionExpression:"#PhoneId &lt;&gt; :PhoneId",
        ExpressionAttributeNames: { '#PhoneId': 'PhoneId' },
        ExpressionAttributeValues: { ":PhoneId": 123 },
        Item: phoneObject
      };
  
      docClient.put(params, function(err, data) {
        if (err) {
          console.error(err);
          reject(err);
        } else {
          resolve(data);
        }
      });
    });
  </code></pre>