MongoDB โ€” MongoDB Compass & mongosh CLI

๐Ÿƒ MongoDB 7.0+ ๐ŸŸข Chapter 5 of 50 ๐Ÿ“‚ Phase 01: MongoDB & NoSQL Basics ๐Ÿ“… 2026 Edition

Master the visual features of MongoDB Compass and the command-line REPL environment of mongosh. Learn how to run scripts, visualize indexes, and inspect schema structures.

1MongoDB Compass Features Overview

MongoDB Compass is the official graphical user interface (GUI). It allows developers and DBAs to visually query, analyze, and optimize MongoDB data without typing raw commands.

  • Documents Tab: View records in Tree View, JSON View, or Table View. Edit or delete documents with single-click buttons.
  • Schema Tab: Analyze field types, sampling data to inspect data cleanliness and missing fields.
  • Explain Plan Tab: Visually inspect query execution stages (IXSCAN vs COLLSCAN).
  • Aggregations Pipeline Builder: Build multi-stage aggregation pipelines with instant intermediate stage previews.
2Mastering the mongosh Interactive REPL

mongosh is a modern Node.js-based REPL environment that supports ES6 JavaScript syntax, asynchronous promises, and custom helper methods.

Useful mongosh Shortcuts & Commands
// List databases
show dbs

// Switch database context
use company_db

// Show active database name
db

// List collections
show collections

// Run inline JavaScript loops in mongosh
for (let i = 1; i <= 5; i++) {
  db.logs.insertOne({ logId: i, timestamp: new Date() });
}

// Print collection statistics
db.logs.stats()
3Visual vs CLI Workflow Comparison
Taskmongosh CLIMongoDB Compass GUI
Quick CRUD Testingโšก Extremely fast with command historyGood for visual visual editing
Building Aggregation PipelineRequires manual JSON array syntaxโœจ Visual stage-by-stage pipeline editor
Server Admin & ScriptingAutomation scripts via .js filesRead-only inspection
Schema AnalysisRequires aggregations / mapReduceVisual charts showing data types
OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy & tested on MongoDB 7.0+ Standards ยท Last updated August 2026