Typorithm · medium

Database Admin

mongosh-adminmongodbadmincollectionsstats
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Database Admin

0%

mongosh

Inspect and manage a database: db.stats() for size, createCollection to add one, drop() to remove a collection, dropDatabase() to remove all.

db.stats() summarises the current database — document counts, data size, and index footprint at a glance.

createCollection adds a collection explicitly so you can set options like validators or capped size up front.

drop() removes a single collection while dropDatabase() wipes the entire current database, so both are irreversible.

01

db.stats() reports size and counts.

02

db.createCollection() adds a collection.

03

drop() / dropDatabase() delete data permanently.

db.stats()
db.createCollection("orders")
db.orders.drop()
db.dropDatabase()

Read the implementation

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

1. Database stats

db.stats() reports the current database's storage size, object count, and index totals.

db.stats()

2. Create collection

createCollection makes a collection explicitly, useful to set options before any insert.

db.createCollection("orders")

3. Drop collection

drop() deletes a single collection and all of its documents and indexes.

db.orders.drop()

4. Drop database

dropDatabase() removes the entire current database, every collection included.

db.dropDatabase()

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.

Database Admin: Lesson & Practice · Typorithm | ApplyDjinn