Skip to main content

Posts

Showing posts with the label MongoDB

πŸ”₯ MongoDB Index Types Explained — With Real Examples, Colors & Interview Tips

πŸƒ What is MongoDB? MongoDB is a NoSQL document-based database that stores data in JSON-like format. Instead of rows and columns, it uses collections and documents . This makes it super flexible and schema-less — perfect for fast-moving modern apps πŸš€. πŸ’‘ Difference vs SQL Databases: SQL = Tables, Rows, Columns πŸ“Š MongoDB = Collections, Documents πŸ“š ❓Why Indexes Matter Imagine searching a phonebook without alphabetical order — painful, right? πŸ˜… Indexes make your searches faster by letting MongoDB skip scanning every document. ⚡ Tip: Without indexes, MongoDB performs a collection scan — meaning it checks every record. That’s fine for 10 docs... not for 10 million! 🧠 Types of Indexes in MongoDB 1️⃣ Single Field Index Most basic and common. You index one field. db.users.createIndex({ "name": 1 }) 1 = ascending , -1 = descending . Used for queries like { name: "Priya" } . 2️⃣ Compound Index Multiple fields combined to improve multi-fi...

πŸ” “MongoDB OIDC with Spring Boot: Driver Drama & Terraform Troubles (And How I Solved Them)”

  🧩 Introduction Setting up MongoDB with OIDC authentication in a production-grade Spring Boot app sounds simple — until reality strikes. πŸ˜… This post covers two specific issues I faced when integrating MongoDB v8 with Spring Boot 3.3.6 , and deploying the app via Terraform to Cloud Run . If you’re planning the same, ame, save yourself some debugging time and read on. πŸ‘‡ πŸ› Issue #1: MongoDB Driver Compatibility – “Unsupported authMechanism: MONGODB-OIDC” πŸ”₯ The Problem: After upgrading to MongoDB v8 , my app started throwing this error: Unsupported authMechanism: MONGODB-OIDC Turns out, the default MongoDB driver version (5.0.1) pulled in by Spring Boot 3.3.6 isn’t compatible with MongoDB v8, especially when using OIDC authentication . Turns out, the default MongoDB driver version (5.0.1) pulled in by Spring Boot 3.3.6 isn’t compatible with MongoDB v8, especially when using OIDC authentication . ✅ The Fix: Manually specify compatible driver versions ( 5.2.1 or abo...