MongoDB mongorestore and existing collection with records

左心房为你撑大大i 提交于 2019-12-29 11:41:10

问题


I need to import (restore) a collection generated with mongodump into an existing database and I'd like the records to be merged into the existing collection.

Does mongorestore merge the records in the same collection or it will drop the existing collection before restoring the records?


回答1:


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

If you don't use --drop, all documents will be inserted into the existing collection, unless a document with the same _id already exists. Documents with the same _id will be skipped, they are not merged. So mongorestore will never delete or modify any of the existing data by default.



来源:https://stackoverflow.com/questions/4021762/mongodb-mongorestore-and-existing-collection-with-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!