Collections
Collections: free step-by-step lesson with examples, common mistakes, and interview tips — part of MongoDB Tutorial on Toolliyo Academy.
On this page
MongoDB Tutorial · Lesson 8 of 100
Collections
Foundations & CRUD → Queries & Schema → Aggregation & Scale → Atlas & Projects
Foundations & CRUD · 1 — Documents · ~6 min · MongoDB — Foundations
What is this?
A collection is a group of documents — like users, products, or orders. Collections do not enforce one schema by default. You can create them explicitly or by inserting into a new name.
Why should you care?
Clear collection boundaries keep queries fast and code readable. Mixing users and orders in one collection makes every query harder.
See it live — copy this example
Open mongosh or MongoDB Compass, select database nosqlverse, then run the example. Change one field and run again.
use NoSQLVerse
db.createCollection("products")
db.products.insertOne({ sku: "KB-01", name: "Mechanical Keyboard", price: 4499 })
show collections
db.products.stats()
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- createCollection makes products explicitly.
- insertOne adds the first document.
- show collections lists names in the current DB.
- stats() shows count and storage info.
Practice next
- Create the products collection as shown.
- Insert two more products with different fields.
- Run show collections.
- Create readings for IoT samples.
- Rename practice: copy docs to products_v2 with aggregate $out (advanced).
Remember
Collections store related documents. They are schema-flexible by default. Name them after nouns: users, orders, posts.
NoSQLVerse course content collections
lessons, progress, and quizzes live in separate collections so lesson reads stay light.
Outcome: Progress updates do not lock or bloat the lesson catalog documents.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!