1

Wondering if there is any way to write a ConditionExpresson If statement on a Put, a pseudocode example of what i'm looking for:

IF email already exists AND verified equals false 
   THEN allow PUT
IF email already exists AND verified equals true
   THEN don't allow PUT
IF email does not exist
   THEN allow PUT

Cheers

1 Answer 1

1

Ended up figuring it out in a more elegant way:

query.Item = {
    email: email,
    verified: false,
    verifyToken: token
};

query.ExpressionAttributeNames = {
    '#verified' : 'verified'
};

query.ExpressionAttributeValues = {
    ':false' : false,
};

query.ConditionExpression = '#verified = :false OR attribute_not_exists(verified)';
Sign up to request clarification or add additional context in comments.

1 Comment

is there a reason the last verified is plain?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.