Copy one collection data to other in MongoDB

copyTo will copy the data from one collection to other including all the Associated content.



The above command will copy the data from ‘studentDetails’ collection to ‘sDetails’, here there is not necessary that sDetails to be already exists.

Note: While copying the Data, MongoDB will not allow for read or write operations.