Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将生成的集合导入(恢复)mongodump到现有数据库中,并且我希望将记录合并到现有集合中。
mongodump
mongorestore是合并同一集合中的记录还是在恢复记录之前删除现有集合?
mongorestore
mongorestore--drop如果您使用参数,只会删除现有集合。
--drop
如果不使用--drop,所有文档都将插入到现有集合中,除非具有相同的文档_id已经存在。相同的文档_id将被跳过,它们不会被合并。因此mongorestore,默认情况下永远不会删除或修改任何现有数据。
_id