小编Sam*_*Sam的帖子

couchdb中的唯一约束

是否有任何技术/建议来强制执行独特的约束?是的,我们可以创建唯一的密钥,但是我们无法更改密钥和密钥,而且这种方法也不适用于复杂的验证(单独的独特登录,单独的独立电子邮件等......)

例如,帐户应具有唯一的登录名和电子邮件.从这些字段中导出密钥会导致不一致:

key1: "Account-john@example.net-john", { email: "john@example.net", login: "john"}
key2: "Account-mary@example.net-mary", { email: "mary@example.net", login: "mary"}
Run Code Online (Sandbox Code Playgroud)

看起来不错,但是:

key1: "Account-john@example.net-mary", { email: "john@example.net", login: "mary"}
key2: "Account-mary@example.net-mary", { email: "mary@example.net", login: "mary"}
Run Code Online (Sandbox Code Playgroud)

哎呀,现在我们有2个账号登录:"mary"

couchdb

27
推荐指数
3
解决办法
7808
查看次数

标签 统计

couchdb ×1