If you are concerned about speed, I found that using aggregate with $project and $out will be 100 times faster, but not sure if there are any limitations, but you will need to create a set of fields that you want to copy For example:
// Set of fields in the categories collection var setOfFields = {field1:1, field2:1.......} db.demo1.categories.aggregate([{ "$project": setOfFields},{ $out: "demo2.categories"}]);
This copies (projects) the selected set of fields for all documents from demo1.categories to demo2.categories
blueskin Jul 02 '15 at 18:13 2015-07-02 18:13
source share