title: Mongoid batch collection insert: how to get the ids of the newly created items?
body: <p>As explained <a href="https://stackoverflow.com/a/3992570/297471">here</a>, it's fairly easy to batch insert an array of new documents into a MongoDB collection:</p>
  
  <pre><code>batch = [{:name =&gt; "mongodb"}, {:name =&gt; "mongoid"}]  
  Article.collection.insert(batch)
  </code></pre>
  
  <p>What I don't find easy though is how to retrieve the list of newly created ids. Is it possible to code something like:</p>
  
  <pre><code>batch = [{:name =&gt; "mongodb"}, {:name =&gt; "mongoid"}]
  result = Article.collection.insert(batch)
  
  result[:ids] # not real code
  </code></pre>
  
  <p>Thanks in advance!</p>