1. Database stats
db.stats() reports the current database's storage size, object count, and index totals.
db.stats()Typorithm · medium
Step 1 of 8 · intro card
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.
db.stats() reports size and counts.
db.createCollection() adds a collection.
drop() / dropDatabase() delete data permanently.
db.stats()
db.createCollection("orders")
db.orders.drop()
db.dropDatabase()Connect each part of the code to the concept before you type.
db.stats() reports the current database's storage size, object count, and index totals.
db.stats()createCollection makes a collection explicitly, useful to set options before any insert.
db.createCollection("orders")drop() deletes a single collection and all of its documents and indexes.
db.orders.drop()dropDatabase() removes the entire current database, every collection included.
db.dropDatabase()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.