Database Reference
In-Depth Information
Using data tools
In this group, we have two utilities that help us generate or import data in human-readable
formats such as JSON or CSV into or from the MongoDB instance. These are mentioned in
the following lists:
mongoimport
mongoexport
Understanding mongoexport
In order to export data in JSON or CSV formats from the MongoDB instance, developers
can use this utility.
The following is a simple usage of this command:
mongoexport --db mydb --collection posts --out export.json
The preceding command line will connect to a local instance of MongoDB, retrieve all re-
cords from the posts collection of the mydb database in the JSON format, and write all
outputs to the export.json file.
Utilizing mongoimport
The mongoimport utility can help you import the produced export files in JSON, CSV
or TSV formats into the MongoDB instance. The export files can be generated from either
mongoexport or from other third-party export tools.
The following example is a basic usage of this command:
mongoimport --db mydb --collection posts --file export.json
The preceding command line will import the export.json entries into the posts col-
lection of the mydb database. The same instruction can be used for other data formats us-
ing the --type option.
Search WWH ::




Custom Search