title: Mongodb unique sparse index
body: <p>I have created a sparse and unique index on my mongodb collection. </p>
  
  <pre><code>var Account = new Schema({
                  email: { type: String, index: {unique: true, sparse: true} },
                          ....
  </code></pre>
  
  <p>It has been created correctly:</p>
  
  <pre><code>{ "ns" : "MyDB.accounts", "key" : { "email" : 1 }, "name" : "email_1", "unique" : true, "sparse" : true, "background" : true, "safe" : null }
  </code></pre>
  
  <p>But if I insert a second document with a key not set I receive this error:</p>
  
  <pre><code>{ [MongoError: E11000 duplicate key error index: MyDB.accounts.$email_1  dup key: { : null }]
    name: 'MongoError',
    err: 'E11000 duplicate key error index: MyDB.accounts.$email_1  dup key: { : null }',
    code: 11000,
    n: 0,
    ok: 1 }
  </code></pre>
  
  <p>Any hints?</p>