MongoDB: Copy a collection from one database to another

It’s quite simple

db..find().forEach(function(d){ db.getSiblingDB('')[''].insert(d); });

You can do a mongodump of a collection from one database and then mongorestore the collection to the other database.

I used robomongo and it a documents view, just used this query with the right names for collections and databases, I was able to copy around 3000 records in less than a second on my old Macbook air.

Uncategorized

Notice: Theme without comments.php is deprecated since version 3.0.0 with no alternative available. Please include a comments.php template in your theme. in /var/www/fahdmurtaza.com/public_html/wp-includes/functions.php on line 3984

Leave a Reply

Your email address will not be published. Required fields are marked *