Switch to the source database
use sourceDB;
Fetch all documents from the source collection
let documents = db.sourceCollection.find().toArray();
Switch to the target database
use targetDB;
Insert the documents into the target collection
db.targetCollection.insertMany(documents);