title: Mongoose schema: Validating unique field, case insensitive
body: <p>I have a <code>userSchema</code> like so:</p>
  
  <pre><code>var userSchema = new Schema({
      name: {
        type: String
      , required: true
      , validate: [validators.notEmpty, 'Name is empty']
      }
    , username: {
        type: String
      , required: true
      , unique: true
      , validate: [validators.notEmpty, 'Username is empty']
      }
  });
  </code></pre>
  
  <p>The <code>username</code> field is supposed to be unique. Mongoose will throw an error if this username already exists in the database. However, it is not case insensitive, which I need it to be.</p>
  
  <p>Am I right in thinking that the only way to achieve a case insensitive unique check is to write my own validation rule, which will perform a query on the collection? Is it OK to write validation checks like this, creating more connections to the collection? I will need to do something similar for <code>email</code>, too.</p>