Skip to content

πŸƒ MongoDB Learning Lab Practical codes, analytics queries & real world database skills building my NoSQL expertise step-by-step.

Notifications You must be signed in to change notification settings

Ashwin18-Offcl/MongoDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MongoDB Thumbnail

πŸƒ MongoDB Learning Lab – by Ashwin Panbude

Practical MongoDB codes, real-world queries, and data-analytics focused learning.


🧠 About This Repository

This repo is my MongoDB practice space where I learn and teach myself:

  • How to use MongoDB as a NoSQL database for projects.
  • How to write clean, optimised queries for analytics & reporting.
  • How to design better data models for real-world applications.

All examples are written in a way that students, beginners, and data analysts can easily follow.


πŸ—‚ Repository Structure (Planned)

You can create folders like this in your repo:

MongoDB/
 β”œβ”€β”€ 01_Basics/
 β”‚    β”œβ”€β”€ commands.md
 β”‚    └── intro_notes.md
 β”œβ”€β”€ 02_CRUD/
 β”‚    β”œβ”€β”€ insert_examples.md
 β”‚    β”œβ”€β”€ find_queries.md
 β”‚    β”œβ”€β”€ update_examples.md
 β”‚    └── delete_examples.md
 β”œβ”€β”€ 03_Query_Operators/
 β”œβ”€β”€ 04_Aggregation/
 β”œβ”€β”€ 05_Data_Modeling/
 β”œβ”€β”€ 06_Indexing_Performance/
 β”œβ”€β”€ 07_NodeJS_Integration/
 └── README.md

Step-by-Step Learning Path

1️⃣ MongoDB Basics

  • What is MongoDB, BSON, Collections, Documents
  • Installing & connecting with mongosh
  • Basic commands: show dbs, use, show collections, db.dropDatabase()

Sample commands:

// check DB
show dbs;
use my_learning_db;
db;

2️⃣ CRUD Operations (Create, Read, Update, Delete)

  • Insert documents with insertOne / insertMany
  • Read data using find, findOne, projections
  • Update using $set, $inc, $push, $addToSet
  • Delete using deleteOne, deleteMany

Example:

// Create
db.students.insertOne({ name: "Ashwin", course: "MongoDB", active: true });

// Read
db.students.find({ active: true }, { _id: 0, name: 1, course: 1 });

// Update
db.students.updateOne(
  { name: "Ashwin" },
  { $set: { active: false }, $inc: { attempts: 1 } }
);

// Delete
db.students.deleteOne({ name: "Ashwin" });

3️⃣ Query Operators & Filters

  • Comparison: $gt, $gte, $lt, $lte, $eq, $ne
  • Logical: $and, $or, $not, $nor
  • Array & element: $in, $nin, $all, $exists, $size

Example:

// students with marks between 60 and 90
db.students.find({
  marks: { $gte: 60, $lte: 90 }
});

// active students in selected courses
db.students.find({
  active: true,
  course: { $in: ["MongoDB", "Node.js", "Data Analytics"] }
});

4️⃣ Sorting, Limiting & Pagination

  • sort() – ascending / descending
  • limit() – top N records
  • skip() – for pagination

Example:

// top 5 highest scorers
db.students.find().sort({ marks: -1 }).limit(5);

// simple pagination
db.students.find().skip(10).limit(10);

5️⃣ Aggregation Framework

  • $match – filter
  • $group – aggregate (sum, avg, count, min, max)
  • $project – reshape fields
  • $sort, $limit, $lookup, $unwind

Example: Average marks per course

db.students.aggregate([
  { $match: { active: true } },
  {
    $group: {
      _id: "$course",
      avgMarks: { $avg: "$marks" },
      totalStudents: { $sum: 1 }
    }
  },
  { $sort: { avgMarks: -1 } }
]);

6️⃣ Data Modeling Experiments

  • Designing embedded vs referenced structures

  • Handling one-to-many / many-to-many relationships

  • Structuring collections for:

    • Student–Course–Result
    • Tasks–Projects
    • Orders–Customers

Sample embedded model:

db.courses.insertOne({
  title: "MongoDB Basics",
  level: "Beginner",
  instructor: {
    name: "Ashwin",
    experienceYears: 3
  }
});

7️⃣ Indexing & Performance

  • Creating single-field and compound indexes
  • Analyzing queries with explain()
  • Understanding when NOT to overuse indexes

Example:

// index on email
db.students.createIndex({ email: 1 }, { unique: true });

// check indexes
db.students.getIndexes();

8️⃣ Integration with Node.js (Planned)

Folder: 07_NodeJS_Integration/

  • Connecting using MongoDB Node.js driver
  • Basic CRUD from Node.js
  • Environment variables for secure connection strings

Mini example:

const { MongoClient } = require("mongodb");
const client = new MongoClient("mongodb://localhost:27017");

async function run() {
  await client.connect();
  const db = client.db("my_learning_db");
  const students = db.collection("students");

  const data = await students.find({ active: true }).toArray();
  console.log(data);

  await client.close();
}
run();

🧩 Skills Highlighted in This Repo

  • MongoDB fundamentals (DB, collection, document)
  • CRUD operations & query operators
  • Aggregation for analytics
  • Data modeling & schema design thinking
  • Indexing and basic performance tuning
  • Backend + database thinking (Node.js integration)

🏷️ Tags / Topics

GitHub topics: mongodb, nosql, database, crud, aggregation-framework, data-analytics, data-modeling, nodejs, learning-notes, tutorials

Social hashtags: #MongoDB #NoSQL #DataAnalytics #BackendDeveloper #DatabaseDesign #LearningInPublic #AshwinPanbude


About

πŸƒ MongoDB Learning Lab Practical codes, analytics queries & real world database skills building my NoSQL expertise step-by-step.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published