0

I have two collections , one where all documents are stored and the other where the documents will be stored after processing. I am new with mongo and would like to know if there is any method to copy the documents from one collection to the other ?

2 Answers2

2

Try this:

db.firstColllection.aggregate([
    {$limit: 10},
    {$out: "secondCollection"}
])
Radosław Miernik
  • 4,004
  • 8
  • 33
  • 36
gaurav singh
  • 1,376
  • 1
  • 15
  • 25
0

To copy all files, we can use db.source.copyTo("target") as well