title: How to extract duplicate key name from a MongoError (E11000) in Javascript?
body: <p>I have a collection with a field 'email' in MongoDB and a unique index on this field.
  If I try to insert a document with an existing 'email' I get the following error </p>
  
  <pre><code>error:  name=MongoError, message=E11000 duplicate key error index: testDB.users.$email_1 dup key: { : "vivek@test.com" }, index=0, code=11000, errmsg=E11000 duplicate key error index: testDB.users.$email_1 dup key: { : "vivek@test.com" }
  </code></pre>
  
  <p>Is there a proper way to get the exact key name from the error message to help identify the exact key that caused the duplicate key error i.e how to extract the 'email' from the error message above?</p>