Clone a collection in MongoDB

Yet again the MongoDB documentation comes to the rescue

assuming that the collection actually is named “demo1.categories”:

db.demo1.categories.find().forEach( function(x){db.demo2.categories.insert(x)} );

Leave a Comment