MongoDB Terminal Simulator
Practice MongoDB queries in an interactive browser terminal. Learn find and projections, query operators like $lt, $gt, and $in, sort, skip, limit, countDocuments, insert, update, delete, and the aggregation pipeline with $match, $group, and $sort, against a small e-commerce dataset that runs live in your browser.
Category: Database
What You Will Learn
- Read documents with find() and filter them with a query document
- Return only the fields you need with a projection
- Compare values with $lt, $gt, $gte, $lte, and match a set with $in
- Shape a cursor with sort, skip, and limit for ordering and pagination
- Count matches with countDocuments without pulling the documents back
- Write data with insertOne, updateOne, and deleteMany and read the results
- Summarise documents with an aggregation pipeline: $match, $group, and $sort
- Test yourself in Challenge mode by writing queries from a plain-English prompt
Topics covered: mongodb, nosql, mongo, database, documents, find, aggregation, queries, terminal, backend, educational, interactive
// simulator
MongoDB Terminal Simulator
Practice MongoDB queries in an interactive browser terminal. Learn find and projections, query operators like $lt, $gt, and $in, sort, skip, limit, countDocuments, insert, update, delete, and the aggregation pipeline with $match, $group, and $sort, against a small e-commerce dataset that runs live in your browser.
find() basics
Goal: Return every document in the customers collection.
Type "help", run "show collections", or follow the task above.
About this MongoDB simulator
What you'll learn
- How find() reads documents and how a query document filters them
- How projections return only the fields you want, and how _id behaves
- How operators like $lt, $gt, $in, $and, and $or express conditions
- How sort, skip, and limit order and paginate a cursor
- How countDocuments answers "how many" without returning the documents
- How insertOne, updateOne, and deleteMany change data and what they return
- How the aggregation pipeline groups and summarises with $match, $group, and $sort
Key operations covered
- Read: find, findOne, query documents, projections, dot-notation fields
- Filter: $eq, $ne, $lt, $gt, $gte, $lte, $in, $nin, $exists, $and, $or
- Shape: sort, skip, limit, countDocuments
- Aggregate: $match, $group with $sum and $avg, $sort, $project, $count
- Write: insertOne, insertMany, updateOne, updateMany, deleteOne, deleteMany
How the playground runs your queries
Every command runs live in your browser against three small collections (customers, products, orders), evaluated by a lightweight query and aggregation engine. Nothing is sent to a server, so you can experiment freely. The data mirrors the SQL simulator's tables, so you can compare how the same records look as documents versus rows.
Practice on a real MongoDB
A simulator builds intuition fast, but running these against a real database makes them stick. You can spin up a free cluster on MongoDB Atlas or run managed MongoDB on DigitalOcean (referral link; new accounts get a sign-up credit), then paste the same commands into mongosh to run them for real.
Prefer SQL, or want to compare?
The SQL Terminal Simulator uses the same e-commerce data as tables, so you can see the exact difference between a document find() and a SQL SELECT. The Database Types Simulator explains when a document database is the right tool in the first place.
Why learn MongoDB this way?
- Document queries click fastest when you can change a filter and see the documents change.
- find(), projections, and the aggregation pipeline cover most day-to-day MongoDB work.
- Reading real results builds the instinct you need for app code, debugging, and interviews.
Overview
MongoDB stores documents instead of rows, and you query it with JavaScript-style calls in the mongo shell rather than with SQL. This simulator runs a subset of that shell in your browser against three small collections, customers, products and orders, which hold the same e-commerce data as the SQL simulator so you can compare the two models directly. The lessons cover find() basics, projections that choose which fields come back, query operators such as $gt and $in, sorting and limiting, paging with skip, counting documents, inserting, updating and deleting documents, and the aggregation pipeline with $match and $group. Every command is evaluated live by a small query and aggregation engine, so a filter you invent behaves like the examples. Orders hold their line items inside the document, which shows the main design difference from a relational schema: data that is read together is often stored together. A separate challenges mode adds query exercises, and nothing is sent to a server, so you can experiment freely.
Try this
- Run db.customers.find() and then add a projection so only the name and country fields come back.
- Open "Matching a set with $in" and filter products by several categories at once.
- Work through "Aggregation: $match + $group" to filter products by price and count them per category with an average price, then compare it with GROUP BY in the SQL simulator.
Frequently asked questions
- What is a projection in MongoDB?
- The second argument to find(), which chooses the fields to return. For example, find({}, { name: 1, _id: 0 }) returns only the name field.
- What is the MongoDB aggregation pipeline?
- A sequence of stages, such as $match, $group, $sort and $project, that each transform the documents passed to them. It does the job that WHERE, GROUP BY and ORDER BY do in SQL.
- When should I use MongoDB instead of a relational database?
- When your data is naturally document shaped and read together, and the schema changes often. If you need many-to-many joins or strict multi-row transactions across tables, a relational database is usually simpler.
Try next
// simulator
SQL Terminal Simulator
Practice SQL in an interactive browser terminal. Learn SELECT, WHERE, ORDER BY, DISTINCT, aggregates, GROUP BY, HAVING, JOINs, subqueries, and window functions against a small e-commerce schema, with single-table queries evaluated live and verified Postgres output.
// simulator
PostgreSQL Terminal Simulator
Practice the psql tool and Postgres engine in an interactive browser terminal. Explore with meta-commands, read real EXPLAIN plans, add an index to turn a sequential scan into a bitmap index scan, and use BEGIN and ROLLBACK to make changes safe, all against a small e-commerce database with verified PostgreSQL output.
// simulator
Database Indexing Simulator
Learn how database indexes work with an interactive simulator. See the difference between full table scans and index seeks, understand B-tree structure, and learn when to create indexes.