title: how to index a username in mongo with case-insensitively?
body: <p>I am coding a webservice where users can pick a username that has to be case-insensitive unique. However I want to allow them to use a case-sensitive version of their username.</p>
  
  <p>What is the best way to check at insert that the username doesn't have a case-insensitive duplicate? I currently see 2 ways of doing this:</p>
  
  <ul>
  <li>storing both a lowercase version and another version with the case entered by the user, and indexing only the lowercase version</li>
  <li>store only the version with the case entered by the user and lowercase it for comparison, which defeats the purpose of the index I suppose</li>
  </ul>
  
  <p>Is there a better way?</p>