title: How to recover from error during bulk insert in MongoDB
body: <p>I am creating a web application with MongoDB.
  Now I am creating admin pages, which enable administrators to add or remove items on the website.
  On the page, bulk import feature will be added, which makes it possible to import contents from local CSV files.
  The problem is how to implement the feature.</p>
  
  <p>The simplest approach is to convert uploaded CSV files into JSON and just insert them using <code>db.items.insert([{...}, {...}, ...])</code> statement.</p>
  
  <p>If <code>null</code> is returned by <code>db.getLastError()</code>, the import is succeeded. There is no problem.</p>
  
  <p>However, what should be done if an error occurred during the bulk insert?
  Because there is no transaction, the inserted items cannot be rolled back.
  Therefore, retrying the insert will result in duplicated documents.</p>
  
  <p>What is the best way to solve this problem?</p>