Search code examples
mongodbnosqlbson

How to add external collection to existing database in MongoDB


I want to add a existing .bson file to a database that i have created in MongoDB. I tried using db.collection.copyto() and db.cloneCollection() but no luck.

if anybody could help with any particular method or other way to do the same. PS : I am new to MongoDB.


Solution

  • You can use mongorestore

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