Importing Data into MongoDB
You now know how to get your collection data out of MongoDB and into an easy-to-use format on disk. But say that you have this file on disk, and you want to share it with someone with their own MongoDB database? This situation is where mongoimport
comes in handy. As you may have guessed from the name, this command is essentially the reverse of mongoexport
, and it is designed to take the output of mongoexport
as an input into mongoimport
.
However, it is not only data exported from MongoDB that you can use with mongoimport
. The command supports JSON, CSV and TSV formats, meaning data extracted from other applications or manually created can still be easily added to the database using mongoimport
. By supporting these widespread file formats, the command becomes an all-purpose way to load bulk data into MongoDB.
As with mongoexport
, mongoimport
operates on a single target collection within the specified database. This means that if you wish to import data...