MongoDB 如何将外部集合添加到现有数据库

How to add external collection to existing database in MongoDB

我想将现有 .bson 文件添加到我在 MongoDB 中创建的数据库中。我尝试使用 db.collection.copyto()db.cloneCollection() 但运气不好。

如果有人可以帮助使用任何特定方法或其他方式来做同样的事情。 PS:我是 MongoDB 的新手。

您可以使用mongorestore

mongorestore --database dbName --collection collectionName /path/file.bson