title: Mongoose getter / setters for normalizing data
body: <p>I have <code>User</code> schema which has a <code>username</code> field. I would like this field to be case sensitive, so that users may register names such as <code>BobDylan</code>. However, I need my schema to validate new entries to check there are no duplicates, incase sensitive, such as <code>bobdylan</code>.</p>
  
  <p>My research has taught me that I should create an additional field in the schema for storing a lower case / upper case version, so that I can easily check if it is unique. My question is, how would I achieve this with the Mongoose API?</p>
  
  <p>I have tried using a <code>set</code> function, such as:</p>
  
  <pre><code>UserSchema.path('username_lower_case').set(function(username_lower_case) {
    return this.username.toLowerCase()
  });
  </code></pre>
  
  <p>However, this function doesn't seem to be running. I basically need to tell <code>username_lower_case</code> to be whatever <code>username</code> is, but in lower case.</p>