title: How to check if the EmaiID already exists or not in the dynamoDB?
body: <p>Iam using node js in the lambda function. When the user tries to put some data in the dynamo DB it should check whether the emailID exists in the db or not...Only when the emailID not exists data's should be updated in the DB...If the emailID exists it should prompt the user that emilID already exists...</p>
  
  <p><strong>Below is my code which i used to put data into the db...But it won't check whether the emailID exists or not....I need to check whether the emilID exists or not in the db...Only if not exists data's should be updated</strong>...Ho to do that pls help me</p>
  
  <pre><code>enter code here
  
  var docClient = new AWS.DynamoDB.DocumentClient();
  
  
  exports.handler = (event, context, callback) =&gt; {
      // TODO implement
  
     var tableName = "Test";
  
      console.log(event.EmailID)
  
      var parms = {
          TableName : tableName,
         Item : {
              "EmailID" : event.EmailID,
              "CustomerName" : event.CustomerName,
              "PersonName" : event.PersonName,
              "EmailSent" : event.EmailSent,
               "Password" : event.Password
          }
      };
  docClient.put(parms, function(err, data)
  {
     if (err){
         callback(err)
     }
     else
     {
         callback(null,"Successfully updated data!!!")
     }
  })
  };
  </code></pre>
  
  <p>KeyconditionExpression:</p>
  
  <pre><code>        const AWS = require('aws-sdk');
  var doc
  
  Client = new AWS.DynamoDB.DocumentClient();
  
  
      var tableName = "Testing";
  
      exports.handler = (event, context, callback) =&gt; {
  
  
  
      var EmailID = event.EmailID; // or any other var which is having emaiID
  
         console.log(event)
  
      var params=  {
               TableName: 'Testing',
  
               Key: {ConditionExpression: 'attribute_exists(event.EmailID)'
                  }
      };
  
  
  
  
      docClient.get(params, function(err, data){
          if(err){
              callback(err, data);
          }else{
              callback(err, data);
         }
  
  
      });
      }
  </code></pre>