title: Mongoose, set default to null and unique
body: <p>I am trying to create a User Schema that has a key of 'facebookid', which is a unique value that is only given when a user signs up with facebook, but not when a user signs up through google or locally. When a user signs up locally, the facebookid is set to null as a default. However I am getting the error: <code>'insertDocument :: caused by :: 11000 E11000 duplicate key error index: db22.users.$facebookid_1  dup key: { : null }'</code></p>
  
  <p>Here is the Schema:</p>
  
  <pre><code>let UserSchema = new Schema({
      facebookid: {
          type: String,
          required: false, // only required for facebook users
          unique: true,
          default: null
      },
      // more details + keys below ...
  })
  </code></pre>
  
  <p>So how can I allow duplicate entries for the key facebookid if the value is null if I also want entries to be unique?</p>
  
  <p>i.e I don't want to see two similar String entries: <br/>
  not okay:
  <br/></p>
  
  <pre><code>* User: {_id: 123, facebookid: '4325',username:'joe'}
  * User: {_id: 432, facebookid: '4325', username: 'pat'}
  </code></pre>
  
  <p>okay: 
  <br/></p>
  
  <pre><code>* User: {_id: 123, facebookid: null,username:'joe'}
  * User: {_id: 432, facebookid: null, username: 'pat'}
  </code></pre>