Restoring single collection in an existing mongodb
If you want to restore a single collection then you have to specifiy the dump file of the collection. The dump file of the collection is found in the 'dump/dbname/' folder. So assuming your dump folder is in your current working directory, the command would go something like -
mongorestore --db mydbname --collection mycollection dump/mydbname/mycollection.bson
I think this is now done with the --nsInclude
option:
mongorestore --nsInclude test.purchaseorders dump/
dump/
is the folder with your mongodump data, test
is the db, and purchaseorders
is the collection.
https://docs.mongodb.com/manual/reference/program/mongorestore/