copy a collection from one database to another in MongoDB?
clone collections from one database to another in MongoDB?


Source DB: sourcedb

Destination DB: distdb

Step:1
>use 
sourcedb;
switched to db sorucedb

> show collections;
Show collections;

Step:2
>db.copyThisCollectionToSampleDatabaseDemo.find().forEach(function(send){

db.getSiblingDB('distdb')['copyThisCollectionToSampleDatabaseDemo'].insert(send); });

Note: Copied all collections into new source( sourcedb)

Step:3
>use dis
db;
switched to disdb

> show collections;
Show collections;

Comments

Popular posts from this blog