我正在将 dynamoDB 与 node js express 项目一起使用,其中用户名和电子邮件地址都应该是唯一的,尝试如下但没有用:
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,
});
}
});
请问有什么帮助吗?