MongoDB mongorestore和具有记录的现有集合 [英] MongoDB mongorestore and existing collection with records

查看:150
本文介绍了MongoDB mongorestore和具有记录的现有集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将用mongodump生成的集合导入(还原)到现有数据库中,我希望将记录合并到现有集合中.

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.

mongorestore是将记录合并到同一集合中,还是会在还原记录之前删除现有集合?

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

推荐答案

mongorestore仅在使用--drop参数时才会删除现有集合.

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

如果不使用--drop,则所有文档都将插入到现有集合中,除非已经存在具有相同_id的文档.具有相同_id的文档将被跳过,它们不会合并.因此,mongorestore默认情况下永远不会删除或修改任何现有数据.

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.

这篇关于MongoDB mongorestore和具有记录的现有集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆