title: Unique constraints in couchdb
body: <p>Are there any techniques/proposals to enforce unique constraints? Yes, we can create key that's unique, but we cannot change key and keys and also this approach is not suitable for complicated validation (separate unique login, separate unique email, etc...)</p>
  
  <p>For example, an Account should have
  unique login and email. Deriving a key
  from this fields will result in
  inconsistency:</p>
  
  <pre><code>key1: "Account-john@example.net-john", { email: "john@example.net", login: "john"}
  key2: "Account-mary@example.net-mary", { email: "mary@example.net", login: "mary"}
  </code></pre>
  
  <p>Looking good, but:</p>
  
  <pre><code>key1: "Account-john@example.net-mary", { email: "john@example.net", login: "mary"}
  key2: "Account-mary@example.net-mary", { email: "mary@example.net", login: "mary"}
  </code></pre>
  
  <p>Oops, now we have 2 accounts with login: "mary"</p>