Importing Multiple Json Files At Once Into Mongodb

Viewed 1015

I know that we can use the mongoimport command to insert one json file into a mongodb database:

mongoimport --jsonArray --db [dbname] --collection [collectionname] --file filename.json

But are there any command that let me insert multiple json files at once?

1 Answers

On mac

cd jsonfilesfolder
ls -1 *.json | while read jsonfile; do mongoimport -d shop --file $jsonfile --type json; done

Reference

Related