title: how to check if non-key attribute already exists in dynamodb using ConditionExpression?
body: <p>I want to insert into users table only if userId, email and username does not exist ( want these to be unique). <br>
  userId is the primary key ( Hash key, data type - Number ). <br>
  username and email are non-key attributes ( both string ).</p>
  
  <p>Here is how i tried:</p>
  
  <pre><code>response = userTable.put_item(
  Item={
      'userId': userIdNext,
      'accType': 0,
      'username': usernameInput,
      'pwd': hashedPwd,
      'email': emailInput
  },
  ConditionExpression = "(attribute_not_exists(userIdNext)) AND (NOT (contains (email, :v_email))) AND (NOT (contains(username, :v_username)))",
  ExpressionAttributeValues={
      ":v_email": emailInput,
      ":v_username": usernameInput
  }
  )
  </code></pre>
  
  <p>I tried to follow the aws documentation for logical operators and condition expression from here: <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html" rel="noreferrer">AWS Conditional Expressions</a></p>
  
  <p><strong>But it is inserting everytime into table even if username or email already exists in the db.</strong> <br>( i am giving new userIdNext as it is primary key and cannot be a duplicate )</p>
  
  <p>I am using Python implemetation <strong>boto3</strong></p>