Anjansai
Anjansai

Reputation: 47

How to merge two collections into one without any conditions

I have two Different collections named X and Y i have to just send these two collections data into a new collection Z.
Is it possible to just send the two collections data into one.

I can see many similar questions but with many conditions in the data so here i don't need any conditions just clubbing the two collections of data into new collection.

Upvotes: 0

Views: 40

Answers (1)

Jayadevan
Jayadevan

Reputation: 1342

You can use copyTo command.

db.myt1.copyTo('myt3'); 
db.myt.copyTo('myt3');

Now we have myt3 as a copy of myt1 and myt collections.

Upvotes: 1

Related Questions