1. Import JSON
mongoimport loads JSON, CSV, or TSV from a file into a named collection.
mongoimport --db shop --collection users --file users.jsonTyporithm · medium
Step 1 of 8 · intro card
mongosh
Move data with mongoimport/mongoexport for human-readable JSON or CSV, and mongodump/mongorestore for full binary backups.
mongoimport and mongoexport handle one collection at a time in text formats like JSON and CSV, ideal for sharing or seeding data.
mongodump and mongorestore work in binary BSON and capture entire databases including indexes, making them the tool for backups.
Pick text tools for portability and migrations; pick dump/restore for fidelity and disaster recovery.
mongoimport / mongoexport move JSON or CSV per collection.
mongodump / mongorestore handle binary BSON backups.
Use --db and --collection to scope the operation.
mongoimport --db shop --collection users --file users.json
mongoexport --db shop --collection users --out users.json
mongodump --db shop
mongorestore dump/Connect each part of the code to the concept before you type.
mongoimport loads JSON, CSV, or TSV from a file into a named collection.
mongoimport --db shop --collection users --file users.jsonmongoexport writes documents from one collection out to a JSON or CSV file.
mongoexport --db shop --collection users --out users.jsonmongodump produces a binary BSON backup of the database into a dump/ directory.
mongodump --db shopmongorestore reads a dump/ directory and rebuilds its databases and collections.
mongorestore dump/Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.