db

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: Database and collection discovery

What it does

The database object selected in the current mongosh session.

Syntax

db

Use case

Inspect the active database and call its collection methods.

db: practical example
db
💡 Explanation The database object selected in the current mongosh session. When to use it Inspect the active database and call its collection methods.
Key Takeaways
  • The database object selected in the current mongosh session.
  • Typical use: Inspect the active database and call its collection methods.