As explained here, it's fairly easy to batch insert an array of new documents into a MongoDB collection:
batch = [{:name => "mongodb"}, {:name => "mongoid"}]
Article.collection.insert(batch)
What I don't find easy though is how to retrieve the list of newly created ids. Is it possible to code something like:
batch = [{:name => "mongodb"}, {:name => "mongoid"}]
result = Article.collection.insert(batch)
result[:ids] # not real code
Thanks in advance!