Typorithm · medium

Import & Export

mongo-import-exportmongodbimportexportbackup
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Import & Export

0%

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.

01

mongoimport / mongoexport move JSON or CSV per collection.

02

mongodump / mongorestore handle binary BSON backups.

03

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/

Read the implementation

Connect each part of the code to the concept before you type.

1. Import JSON

mongoimport loads JSON, CSV, or TSV from a file into a named collection.

mongoimport --db shop --collection users --file users.json

2. Export JSON

mongoexport writes documents from one collection out to a JSON or CSV file.

mongoexport --db shop --collection users --out users.json

3. Binary backup

mongodump produces a binary BSON backup of the database into a dump/ directory.

mongodump --db shop

4. Restore backup

mongorestore reads a dump/ directory and rebuilds its databases and collections.

mongorestore dump/

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Import & Export: Lesson & Practice · Typorithm | ApplyDjinn