I am using dynamoDB with a node js express project, in which username and email address both shlould be unique, tried like below but didn't work:
const params = {
TableName: "users",
Item: {
id: uuidv4(),
username,
email,
password,
},
ConditionExpression: "attribute_not_exists(email) AND attribute_not_exists(SK)",
};
db.put(params, (err, data) => {
if (err) {
return res
.status(409)
.send({ success: false, message: `User already exist ${err}` });
} else {
return res.status(200).send({
success: true,
message: "User added succcessfully",
data: data,
});
}
});
any help please?