I am new to mongodb and want to know about importing a json file from one server to another. I tried the following command mongoimport -d tes
I used the solutions here to add a shell function to my bash profile for doing this quickly.
My example depends on the mongo export outputting each collection as a file with the collection name and .metadata.json extension.
function mimport() {
for filename in *; do
collection="${filename%.metadata.json}";
mongoimport --db $1 --collection $collection --file $filename;
done
}
Use in the path of the export files, passing the DB name to the command...
mimport my_db
Will load all collections into the DB at localhost.