开发者

MongoDB mongorestore and existing collection with records

开发者 https://www.devze.com 2023-01-21 05:04 出处:网络
I need to import (restore) a collection generated with mongodum开发者_如何学Cp into an existing database and I\'d like the records to be merged into the existing collection.

I need to import (restore) a collection generated with mongodum开发者_如何学Cp 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消