MongoDB mongorestore and existing collection with records

I need to import (restore) the collection generated by mongodump into an existing database, and I would like the records to be merged into an existing collection.

Does mongorestore records in one collection or delete an existing collection before restoring records?

+57
mongodb mongorestore
Oct 26 '10 at 8:08
source share
1 answer

mongorestore will only delete the existing collection if you use the --drop argument.

If you do not use --drop , all documents will be inserted into the existing collection if the document with the same _id no longer exists. Documents with the same _id will be skipped, they will not be merged. Therefore, mongorestore will never delete or modify any existing default data.

+84
Oct 26 '10 at 8:27
source share



All Articles