I have to make a key unique in dynamo db. i want to make my email unique, if the email is already existed in database then when i enter next time the same email id then it should not enter to database. it should give a response "email already exists". How can i get that?
This is the response which i am getting an employee..in this example i dont need to insert another email value like hari@gmail.com
{
"defaultEmp": 0,
"empName": "Hari",
"statuses": 1,
"designation": "store keeper",
"id": 1,
"storeId": 1,
"email": "hari@gmail.com"
}
您无需为电子邮件创建ID即可使其唯一。.只需在用户创建帐户时检查db中是否存在该电子邮件即可。.就这样..无需进行其他字段检查。
Choose accordingly, what you want to achieve partition key vs composite key .
1: you can use the designation as a partition key and email as a sort key Using sort key .
2: you can use the email as a Partition key and designation as a Sort key or only email as Partition key.
3: simply select email as Partition key.
NOTE:
-make sure email and designation composite Primary key are unique else it will overwrite data.
-This is my first contribution :) Correct me if I am wrong and feel free to give any suggestion. Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.