I want to insert users into the table only if userId, email and username do not exist (you want them to be unique).
userId - primary key (Hash key, data type - Number).
username and email address are non-key attributes (both lines).
Here is how I tried:
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 } )
I tried here to execute aws documentation for boolean operators and condition expressions: AWS conditional expressions
But it inserts each time into the table, even if the username or email address already exists in db.
(I give the new userIdNext as the primary key and cannot be a duplicate)
I am using Python boto3 implementation
source share