<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prayush Adhikari</title>
    <description>The latest articles on DEV Community by Prayush Adhikari (@adhikareeprayush).</description>
    <link>https://dev.to/adhikareeprayush</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1274304%2Fc9da5e02-7345-4dd7-9b65-e75e5811bca4.png</url>
      <title>DEV Community: Prayush Adhikari</title>
      <link>https://dev.to/adhikareeprayush</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adhikareeprayush"/>
    <language>en</language>
    <item>
      <title>I Spent a Weekend Binge-Watching LLM Content So You Don't Have To (Okay, You Still Should, But Here's the Map)</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Sun, 27 Sep 2026 13:58:09 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/i-spent-a-weekend-binge-watching-llm-content-so-you-dont-have-to-okay-you-still-should-but-1im1</link>
      <guid>https://dev.to/adhikareeprayush/i-spent-a-weekend-binge-watching-llm-content-so-you-dont-have-to-okay-you-still-should-but-1im1</guid>
      <description>&lt;p&gt;Real talk: everyone and their uncle is "using AI" right now, but ask most people what a token actually is and you get a blank stare. I was in that camp too, not long ago. So this month I did something slightly unhinged — I sat down and went through three completely different explanations of how LLMs actually work, back to back, and it clicked in a way that no single YouTube video was ever going to give me.&lt;/p&gt;

&lt;p&gt;Here's the thing: each of these sources attacks the problem from a totally different altitude. One gets its hands dirty with code and whiteboard sketches. One skips theory entirely and just shows you how to build something. And one is basically a full grad-school course crammed into a lecture series. Stack them together and you get something close to an actual curriculum, minus the tuition.&lt;/p&gt;

&lt;p&gt;If you're on the same journey — curious about AI beyond "type prompt, get answer" — I'm breaking down what I learned from each one, and honestly, I'd watch them in the same order I did.&lt;/p&gt;

&lt;p&gt;Big credit up front to the people who actually made this stuff:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Piyush Garg&lt;/strong&gt; — &lt;a href="https://www.youtube.com/watch?v=K45s2PgywvI" rel="noopener noreferrer"&gt;"How LLMs Works? - Overview"&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dev Weekends&lt;/strong&gt; — &lt;a href="https://www.youtube.com/watch?v=qRzK8P_SnaE" rel="noopener noreferrer"&gt;"Level 0 and Level 1 - Gen AI Sessions"&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stanford Online&lt;/strong&gt; — &lt;a href="https://www.youtube.com/playlist?list=PLoROMvodv4rOCXd21gf0CF4xr35yINeOy" rel="noopener noreferrer"&gt;"CME295: Transformers and Large Language Models I, Autumn 2025"&lt;/a&gt; (Afshine and Shervine Amidi)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's get into it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1: What's Actually Happening Inside the Box
&lt;/h2&gt;

&lt;p&gt;If you've ever nodded along in a conversation about AI while quietly having zero clue what "embedding" means, start with Piyush Garg's video. It's not a theory lecture — it's a "let me rip the hood off this thing" video, and it works because it stays concrete the entire time.&lt;/p&gt;

&lt;p&gt;The core message is refreshingly deflating in a good way: ChatGPT, Gemini, Claude — none of it is magic, none of it is sentient. It's math, code, and a lot of data. Even the name gives it away. GPT is basically a spec sheet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Generative&lt;/strong&gt; — it makes new stuff on the fly instead of retrieving and ranking existing pages like a search engine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-trained&lt;/strong&gt; — it already chewed through a mountain of internet text, books, and conversations before you typed anything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformer&lt;/strong&gt; — the architecture underneath all of it, from Google's 2017 paper &lt;em&gt;"Attention Is All You Need."&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From there the video walks you through the actual pipeline your sentence goes through:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tokenization.&lt;/strong&gt; Before a computer can do anything with your text, it needs numbers. A tokenizer chops your sentence into chunks based on a vocabulary, and the size of that vocabulary decides whether you get clean whole-word tokens or things get sliced into subwords and stray characters. Garg demos this live with Hugging Face's &lt;code&gt;transformers&lt;/code&gt; library and Google's Gemma tokenizer, and honestly that's the moment it stops being abstract and starts being "oh, that's literally what's happening."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector embeddings.&lt;/strong&gt; Once you've got tokens, each one gets mapped to a dense vector — we're talking hundreds or thousands of dimensions — that's supposed to encode meaning. The analogy that actually landed for me: think direction and distance. The path from &lt;code&gt;Cat&lt;/code&gt; to &lt;code&gt;Milk&lt;/code&gt; looks a lot like the path from &lt;code&gt;Dog&lt;/code&gt; to &lt;code&gt;Pedigree&lt;/code&gt;. &lt;code&gt;Dog&lt;/code&gt; to &lt;code&gt;Animal&lt;/code&gt; mirrors &lt;code&gt;Man&lt;/code&gt; to &lt;code&gt;Human&lt;/code&gt;. The model isn't memorizing a dictionary — it's storing relationships between concepts, and you can literally go poke at this yourself through the OpenAI embeddings API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Positional encoding.&lt;/strong&gt; Here's a detail a lot of people skip over: Transformers don't read left to right the way you do. Without help, "the dog chased the cat" and "the cat chased the dog" would look identical to the attention mechanism, which — yeah, that's a problem. Positional encoding bolts sine and cosine functions onto the embeddings so word order (and the meaning that comes with it) actually survives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-attention and multi-head attention.&lt;/strong&gt; This is the star of the show, and it's the actual innovation from the 2017 paper everyone name-drops. Self-attention lets every token look at every other token and update itself based on context. That's how the model knows "bank" in "river bank" has nothing to do with "bank" in "ICICI bank" — something the older RNN and CNN architectures genuinely struggled with. Multi-head attention just runs a bunch of these attention processes in parallel, so the model can track multiple relationships at once — a dog, on a train, doing something, being a specific color — all simultaneously instead of one at a time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feed-forward layers, then output.&lt;/strong&gt; These attention blocks stack on top of each other, refining the representation layer by layer, until a final linear layer spits out a probability distribution over the entire vocabulary for "what token comes next." Softmax turns those raw scores into actual probabilities, and &lt;strong&gt;temperature&lt;/strong&gt; decides how safe or how spicy the model gets with its pick — low temperature plays it safe, high temperature gambles on something less likely (and usually more interesting, sometimes more unhinged).&lt;/p&gt;

&lt;p&gt;The video also draws a clean line between &lt;strong&gt;training&lt;/strong&gt; (the model sees known input-output pairs, calculates loss, updates weights via backpropagation) and &lt;strong&gt;inference&lt;/strong&gt; (live deployment — the model just predicts one token at a time, autoregressively, until it hits an end-of-sequence tag, with zero learning happening). Sounds obvious once you say it out loud, but it clears up a lot of confusion about what's actually happening when you're chatting with one of these things.&lt;/p&gt;

&lt;p&gt;What makes this video worth your time isn't that any of it is secret — it's that Garg keeps everything tied to code you can actually run: &lt;code&gt;AutoTokenizer&lt;/code&gt;, the OpenAI embeddings endpoint, a from-scratch PyTorch generation loop with &lt;code&gt;AutoModelForCausalLM&lt;/code&gt;. You walk away with a mental model you can go verify yourself instead of just trusting some guy on YouTube (me included).&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: Cool, Now How Do I Actually Build Something?
&lt;/h2&gt;

&lt;p&gt;Understanding attention mechanisms doesn't teach you how to ship a product. I learned that gap the hard way trying to wire an LLM into a side project with zero idea what I was doing. This is exactly where Dev Weekends' "Level 0 and Level 1" session comes in, and it's the most immediately useful of the three if your goal is writing software instead of passing an exam.&lt;/p&gt;

&lt;p&gt;It starts with the unglamorous stuff that actually matters: &lt;strong&gt;you pay for tokens&lt;/strong&gt;, full stop, and your bill is input tokens (your prompt) plus output tokens (the response). If you've ever gotten a surprise API bill, you already know why this matters more than the fancy theory.&lt;/p&gt;

&lt;p&gt;From there it breaks down the three roles you'll use in basically every single LLM API call:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;System message&lt;/strong&gt; — sets the model's personality and ground rules, invisible to whoever's using your app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User message&lt;/strong&gt; — whatever the human actually typed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assistant message&lt;/strong&gt; — the model's response, generated using both of the above as context.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few engineering patterns get covered here that I think people skip more than they should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Streaming&lt;/strong&gt; (&lt;code&gt;stream=True&lt;/code&gt;) — instead of waiting for the full response, you get it chunk by chunk, which is the entire reason ChatGPT feels like it's "typing" instead of freezing and dumping a wall of text on you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structured output / JSON schemas&lt;/strong&gt; — if you're plugging an LLM into a real system, you cannot have it randomly deciding to wrap its JSON in a friendly little paragraph. Define a schema up front and you kill an entire category of parsing bugs before they happen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool calling / function calling&lt;/strong&gt; — this is the mechanism that lets a model say "I don't know today's weather, but here's a function signature for a weather API, go call it and hand me the result." The model itself never executes anything — it just recognizes when it needs help and passes the ball back to your app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the prompting side, it runs through the standard toolbox: &lt;strong&gt;zero-shot&lt;/strong&gt; (just ask), &lt;strong&gt;few-shot&lt;/strong&gt; (show it examples first), &lt;strong&gt;chain-of-thought&lt;/strong&gt; (make it reason step-by-step before answering), and &lt;strong&gt;ReAct&lt;/strong&gt; (interleaving reasoning with actual tool calls to chew through multi-step problems). I'd read about all of these separately before, but seeing them laid out as a progression — from "just ask" to "reason and act" — made a lot more sense than any individual blog post had.&lt;/p&gt;

&lt;p&gt;The part I found genuinely most useful, though, was the &lt;strong&gt;fine-tuning vs. RAG&lt;/strong&gt; breakdown. Fine-tuning means retraining chunks of the network on your own data — expensive, heavy on compute, and static, since any new information means retraining the whole thing over again. RAG (Retrieval-Augmented Generation) sidesteps all of that by keeping the model frozen and just hooking it up to an external, updatable vector database instead.&lt;/p&gt;

&lt;p&gt;The RAG pipeline breaks down into five steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Parse&lt;/strong&gt; your source documents — PDFs, databases, scraped pages via BeautifulSoup, whatever.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunk&lt;/strong&gt; the text into fixed-size pieces (think 512 tokens) with some overlap (150 tokens) so you're not losing context at the seams.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embed and store&lt;/strong&gt; those chunks in a vector database (ChromaDB, PgVector) along with metadata like source and timestamp.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search&lt;/strong&gt; — turn the user's query into an embedding and run cosine similarity to pull the top-k most relevant chunks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inject&lt;/strong&gt; those chunks into the prompt so the model actually grounds its answer in your data instead of just guessing confidently.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And it doesn't stop at "ship it and pray" — it flags &lt;strong&gt;RAGAS&lt;/strong&gt; as a framework for actually evaluating whether your retrieved context is faithful, your answers are relevant, and you're not quietly hallucinating despite technically having a "grounded" system. That last part is easy to forget. RAG lowers your hallucination risk. It does not erase it. Learn that the easy way, not the hard way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3: The Academic Backbone — Stanford CME295
&lt;/h2&gt;

&lt;p&gt;If the first two are "how it works" and "how you build with it," Stanford's CME295 (taught by Afshine and Shervine Amidi) is the "why it works, rigorously, and where this is all headed" course. It's a full nine-lecture sequence, and it's the one I'd point to if your goal is going from "informed enthusiast" to "person who can actually reason about model design decisions in a room full of people who'd know."&lt;/p&gt;

&lt;p&gt;The syllabus tracks a clean arc:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Transformer&lt;/strong&gt; — core attention mechanics and encoder-decoder structure, covered with academic precision instead of intuition-first analogies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformer-Based Models &amp;amp; Tricks&lt;/strong&gt; — how BERT, GPT, and T5 diverge architecturally, different positional embedding schemes, and the tricks that make large-scale training actually converge instead of blowing up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformers &amp;amp; LLMs&lt;/strong&gt; — the jump from small task-specific models to today's massive general-purpose ones, scaling laws, and emergent capabilities that only show up once you're big enough.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM Training&lt;/strong&gt; — pre-training objectives, dataset prep at scale, and the distributed-cluster/memory-efficiency tricks required to train something this large in the first place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM Tuning&lt;/strong&gt; — Supervised Fine-Tuning, Parameter-Efficient Fine-Tuning (LoRA and friends), and alignment via RLHF and Direct Preference Optimization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM Reasoning&lt;/strong&gt; — how post-training unlocks reasoning, and the increasingly hot idea of scaling &lt;em&gt;test-time&lt;/em&gt; compute instead of just throwing more compute at training.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agentic LLMs&lt;/strong&gt; — designing autonomous agents: task decomposition, memory architectures, tool use, multi-agent coordination.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM Evaluation&lt;/strong&gt; — systematic benchmarking, the "LLM-as-a-judge" approach, and safety/robustness red-teaming.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recap &amp;amp; Current Trends&lt;/strong&gt; — tying it all together and pointing at where frontier research is actually headed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What this course adds that the other two structurally can't is the &lt;em&gt;why&lt;/em&gt;. Garg's video tells you self-attention solves the context problem. Stanford's course is where you'd actually get the math behind scaled dot-product attention, the reasoning behind specific positional embedding choices, and the real tradeoffs between RLHF and DPO for alignment. It's also the only one of the three treating agentic systems and formal evaluation as first-class topics instead of an afterthought bolted on at the end — which, not coincidentally, is exactly where the field's energy is right now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting It All Together
&lt;/h2&gt;

&lt;p&gt;Lined up side by side, these three cover roughly the same ground a CS curriculum would, just compressed into a weekend of watching instead of a semester of tuition:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Piyush Garg&lt;/th&gt;
&lt;th&gt;Dev Weekends&lt;/th&gt;
&lt;th&gt;Stanford CME295&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best for&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Building intuition for the internals&lt;/td&gt;
&lt;td&gt;Shipping real LLM-powered software&lt;/td&gt;
&lt;td&gt;Deep theoretical and research literacy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Single video, whiteboard + code&lt;/td&gt;
&lt;td&gt;Hands-on workshop, live API/RAG demos&lt;/td&gt;
&lt;td&gt;9-lecture university course&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Core focus&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tokens → embeddings → attention → sampling&lt;/td&gt;
&lt;td&gt;API roles, streaming, JSON schemas, tool calling, RAG vs. fine-tuning&lt;/td&gt;
&lt;td&gt;Math foundations, scaling, alignment, reasoning, agents, evaluation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tools shown&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hugging Face &lt;code&gt;transformers&lt;/code&gt;, PyTorch, OpenAI API&lt;/td&gt;
&lt;td&gt;OpenAI API, ChromaDB, LangChain, BeautifulSoup, RAGAS&lt;/td&gt;
&lt;td&gt;Academic frameworks, frontier benchmarks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Honest take: none of these alone gives you the full picture, and that's fine, because they're not trying to. &lt;strong&gt;Garg&lt;/strong&gt; hands you the mechanical model of how a token turns into a prediction. &lt;strong&gt;Dev Weekends&lt;/strong&gt; shows you what to actually do with that model once it's sitting behind an API and your credit card is on the line. &lt;strong&gt;Stanford&lt;/strong&gt; gives you the rigor to understand why the field made the choices it did, and where it's probably going next — reasoning models, agentic systems, evaluation frameworks that can actually keep pace.&lt;/p&gt;

&lt;p&gt;If you're early in this journey, that's the order I'd go: intuition, then application, then theory. Same path I took, minus the part where I procrastinated for two weeks before starting.&lt;/p&gt;

&lt;p&gt;Now go tokenize something.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Connect
&lt;/h2&gt;

&lt;p&gt;I'm Prayush Adhikari, currently grinding through the 8th semester of computer engineering and running an IT club on the side while trying to actually understand the stuff I keep building with. If you've watched any of these three (or have a better resource I'm missing), drop it in the comments — I'm always collecting more.&lt;/p&gt;

&lt;p&gt;Which one are you starting with: the internals video, the build-something workshop, or going straight for the Stanford deep end?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;https://linkedin.com/in/adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;https://github.com/adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Portfolio: &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;https://prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>llm</category>
      <category>machinelearning</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Tutorial Hell Is Real: I Watched 40 Hours of Videos and Built Nothing (Here's How I Escaped)</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Sat, 26 Sep 2026 01:43:16 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/tutorial-hell-is-real-i-watched-40-hours-of-videos-and-built-nothing-heres-how-i-escaped-2ie9</link>
      <guid>https://dev.to/adhikareeprayush/tutorial-hell-is-real-i-watched-40-hours-of-videos-and-built-nothing-heres-how-i-escaped-2ie9</guid>
      <description>&lt;p&gt;Hey there! Let me guess how your week went.&lt;/p&gt;

&lt;p&gt;You watched a full-stack course. Then another one. You nodded along, pausing at the right moments, typing out everything the instructor typed. Everything worked. You felt like a genius.&lt;/p&gt;

&lt;p&gt;Then you opened a blank file to build something on your own, and your brain went completely white.&lt;/p&gt;

&lt;p&gt;Welcome to tutorial hell. I've lived there. I paid rent there for way too long. This post is the map I wish I'd had on the way out.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. How to Know You're Stuck in Tutorial Hell
&lt;/h2&gt;

&lt;p&gt;Be honest with yourself. Tick these off:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You've finished more courses than you've built projects&lt;/li&gt;
&lt;li&gt;You feel like you "get it" while watching, but can't start without a video&lt;/li&gt;
&lt;li&gt;You keep switching to a new language or framework because the old one "wasn't clicking"&lt;/li&gt;
&lt;li&gt;Your bookmarks folder is bigger than your GitHub profile&lt;/li&gt;
&lt;li&gt;You've said the words "I'll start my own project after this course" more than twice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you ticked two or more, you're in. No shame in it. Almost every self-taught developer visits at some point, and plenty of CS students too, because college can be tutorial hell with a syllabus.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why It Feels So Good (and Why That's the Trap)
&lt;/h2&gt;

&lt;p&gt;Here's the 5-year-old version.&lt;/p&gt;

&lt;p&gt;Watching a tutorial is like watching someone cook on TV. You see the knife skills, the perfect sear, the plating. Everything looks easy, and you feel like you learned to cook.&lt;/p&gt;

&lt;p&gt;Then you walk into your kitchen with raw ingredients and no instructions. Suddenly you don't know how hot the pan should be, how to tell if the chicken is done, or what to do when the onions start burning.&lt;/p&gt;

&lt;p&gt;The show never showed you &lt;em&gt;that&lt;/em&gt; part. It showed you the finished path, with every decision already made, every wrong turn already edited out.&lt;/p&gt;

&lt;p&gt;That's the trap. Tutorials remove the exact thing that makes you learn: &lt;strong&gt;the struggle of not knowing what to do next.&lt;/strong&gt; Your brain gets the warm feeling of progress without any of the actual muscle-building.&lt;/p&gt;

&lt;p&gt;Same as the gym. Watching someone lift doesn't make you stronger.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The Real Skill Nobody Teaches
&lt;/h2&gt;

&lt;p&gt;Here's the thing. Programming isn't really about knowing syntax. It's about &lt;strong&gt;taking a vague problem and breaking it down into small steps you can actually solve&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Tutorials never teach that, because the instructor already did the breaking down before hitting record. You only ever see the solved version.&lt;/p&gt;

&lt;p&gt;So to escape, you need to practice the part they skipped: staring at a fuzzy idea, figuring out the first tiny step, doing it, then figuring out the next one. It feels slow and uncomfortable. That discomfort is the learning. Real talk: if it feels easy, you're probably still watching.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. My Escape Method: Watch, Rebuild, Remix
&lt;/h2&gt;

&lt;p&gt;This is the system that actually works for me and for the people in our IT club. Three steps for every tutorial:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Watch (once)
&lt;/h3&gt;

&lt;p&gt;Follow the tutorial once, start to finish. Type along if it helps. This is the only time you're allowed to follow along.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Rebuild (from memory)
&lt;/h3&gt;

&lt;p&gt;Close the tab. Delete the code. Open a blank file and build the same thing again &lt;em&gt;without&lt;/em&gt; the video.&lt;/p&gt;

&lt;p&gt;You will get stuck. You will forget things. Good. Every time you get stuck, spend 15 minutes trying to figure it out yourself before peeking. When you peek, look at only the one piece you need, then close it again.&lt;/p&gt;

&lt;p&gt;This step alone is worth more than five extra tutorials.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Remix (make it yours)
&lt;/h3&gt;

&lt;p&gt;Now change something the tutorial never covered. Building a weather app? Add a feature for saving favorite cities. A to-do app? Add tags or a deadline reminder. A landing page? Rebuild it for a real local business.&lt;/p&gt;

&lt;p&gt;The remix is where you stop being a follower and become a builder. It's also the part that makes your project different from the thousands of identical tutorial clones on GitHub. Recruiters can spot those from a mile away.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Project Ideas That Actually Work for Beginners
&lt;/h2&gt;

&lt;p&gt;Stuck on what to build? Here's a starter list. Pick something small enough to finish in a week.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A tool that solves a tiny annoying problem in your daily life&lt;/li&gt;
&lt;li&gt;A website for a local shop, a relative's business, or your college club&lt;/li&gt;
&lt;li&gt;A tracker for something you already track in a messy spreadsheet (expenses, workouts, study hours)&lt;/li&gt;
&lt;li&gt;A quiz app for a subject you're studying&lt;/li&gt;
&lt;li&gt;A bot that sends you a daily reminder or summary&lt;/li&gt;
&lt;li&gt;A simple dashboard showing data from a free public API&lt;/li&gt;
&lt;li&gt;A personal site that's actually deployed and live&lt;/li&gt;
&lt;li&gt;A cleaner, better-looking version of an app you use and find ugly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice the pattern? They all start from a &lt;strong&gt;real problem you have&lt;/strong&gt;. Motivation is way easier when you're building something you'll actually use.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. When You Get Stuck (You Will)
&lt;/h2&gt;

&lt;p&gt;Getting stuck isn't a sign you're bad at this. It's the job. Here's how I handle it now:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Read the error message. Actually read it.&lt;/strong&gt; Most beginners skip straight to panic. The error usually tells you the file, the line, and what it expected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explain the problem out loud&lt;/strong&gt; to a friend, a rubber duck, or your wall. Half the time you solve it mid-sentence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shrink the problem.&lt;/strong&gt; Delete everything unrelated until you have the smallest piece that still breaks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search with specifics&lt;/strong&gt;, not "my code doesn't work". Paste the exact error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Then ask AI to guide you&lt;/strong&gt;, not to hand you the answer. Say "give me a hint, not the solution." I wrote about this in my last post, so check it out if you missed it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Real talk: the developers who improve fastest aren't the ones who never get stuck. They're the ones who get &lt;em&gt;comfortable&lt;/em&gt; being stuck.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. The Comparison Trap
&lt;/h2&gt;

&lt;p&gt;One more thing, because it quietly kills more beginners than bad tutorials do.&lt;/p&gt;

&lt;p&gt;You'll see someone your age on social media shipping a startup, landing an internship, or posting a huge project. Ignore the urge to compare. You're seeing their highlight reel next to your behind-the-scenes.&lt;/p&gt;

&lt;p&gt;I learned the hard way that the only comparison worth making is you today versus you a month ago. Can you build something now that you couldn't then? Then you're moving.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. A 30-Day Plan to Break Out
&lt;/h2&gt;

&lt;p&gt;If you want something concrete, here's the plan I'd give to a friend:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 1: Rebuild&lt;/strong&gt;&lt;br&gt;
Pick one tutorial project you already finished. Rebuild it from scratch without the video. Expect to struggle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 2: Remix&lt;/strong&gt;&lt;br&gt;
Add two features to that project that were never in the tutorial. Deploy it somewhere public.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 3: Build your own&lt;/strong&gt;&lt;br&gt;
Choose a tiny original idea from the list above. Write down the smallest working version in one sentence, then build only that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 4: Polish and share&lt;/strong&gt;&lt;br&gt;
Write a proper README explaining what it does and why you built it. Put it on GitHub. Post about it, or show it to your club or a friend.&lt;/p&gt;

&lt;p&gt;That's one shipped, original project in a month. That alone puts you ahead of most people still on their fourth course.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Honest Takes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Tutorials aren't evil. They're great for &lt;em&gt;starting&lt;/em&gt;. They're terrible as a &lt;em&gt;destination&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;A finished ugly project beats ten perfect plans.&lt;/li&gt;
&lt;li&gt;Copying code isn't the sin. Not understanding it is.&lt;/li&gt;
&lt;li&gt;Consistency beats intensity. One hour a day beats one heroic weekend.&lt;/li&gt;
&lt;li&gt;Nobody feels ready. Start anyway.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  That's It. Now Go Build Something.
&lt;/h2&gt;

&lt;p&gt;Close this tab. Close the course you're halfway through. Open a blank file and start something small and slightly embarrassing.&lt;/p&gt;

&lt;p&gt;It won't feel great at first. That means it's working.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's Connect
&lt;/h2&gt;

&lt;p&gt;I'm Prayush Adhikari, currently grinding through computer engineering, leading an IT club, and building my own company on the side. I write about Linux, productivity, and the honest side of learning to code.&lt;/p&gt;

&lt;p&gt;If you're stuck in tutorial hell right now, drop a comment and tell me what you're trying to build. I read every one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;linkedin.com/in/adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;github.com/adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Portfolio: &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What project are you building to escape tutorial hell? And what should the next post be: how to build a GitHub profile that gets you noticed, or how to survive your first coding interview?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>productivity</category>
      <category>learning</category>
    </item>
    <item>
      <title>Should You Still Learn to Code in 2026? An Honest Take From a Student Who's Still Grinding</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Thu, 24 Sep 2026 16:32:29 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/should-you-still-learn-to-code-in-2026-an-honest-take-from-a-student-whos-still-grinding-4f3</link>
      <guid>https://dev.to/adhikareeprayush/should-you-still-learn-to-code-in-2026-an-honest-take-from-a-student-whos-still-grinding-4f3</guid>
      <description>&lt;p&gt;So you've seen the videos. "Coding is dead." "AI writes everything now." "Don't bother learning to program."&lt;/p&gt;

&lt;p&gt;Cool. Now you're three weeks into learning Python, staring at a &lt;code&gt;SyntaxError&lt;/code&gt;, wondering if you're wasting your time.&lt;/p&gt;

&lt;p&gt;I get it. I'm a computer engineering student in my final semester, I run an IT club, and I get this exact question all the time: &lt;em&gt;"Bro, is it even worth learning to code anymore?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Short answer: yes. Long answer: yes, but the way you learn has to change. Let me break it down with no hype and no doom.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The Panic Is Real (Let's Not Pretend Otherwise)
&lt;/h2&gt;

&lt;p&gt;I'm not going to tell you everything is fine. It's not all fine.&lt;/p&gt;

&lt;p&gt;Entry-level developer job postings have dropped hard. One 2026 breakdown puts the drop in junior postings at about 67% since 2022, with actual hiring falling even more. That hurts to read when you're the one about to apply.&lt;/p&gt;

&lt;p&gt;But here's the thing most doom videos skip. Stanford's August 2026 revision found a real employment gap for young workers in AI-exposed jobs, yet the researchers themselves call it descriptive rather than proof of cause. And the U.S. Bureau of Labor Statistics still projects growth for software developer roles over the next decade.&lt;/p&gt;

&lt;p&gt;So what's actually happening? The jobs aren't vanishing. They're being &lt;em&gt;rewritten&lt;/em&gt;. The old "take a ticket, write boilerplate, submit a pull request" junior role is under pressure. The new junior role is closer to "understand the problem, direct the AI, check what it gave you, and explain why it's right."&lt;/p&gt;

&lt;p&gt;Real talk: that's a skill you can learn. But only if you learn the basics first.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What AI Actually Replaced
&lt;/h2&gt;

&lt;p&gt;Here's the 5-year-old version.&lt;/p&gt;

&lt;p&gt;Think of AI as a really fast intern who never sleeps, never complains, and types 100x faster than you. Sounds amazing, right?&lt;/p&gt;

&lt;p&gt;The catch: this intern is &lt;em&gt;confidently wrong&lt;/em&gt; once in a while, and it will never tell you when. It'll hand you something that looks perfect, runs fine on the first try, and quietly breaks three days later.&lt;/p&gt;

&lt;p&gt;If you don't understand the work, you can't tell the difference between "correct" and "almost correct." And that gap is exactly where beginners get burned.&lt;/p&gt;

&lt;p&gt;It's the same story as calculators. Calculators didn't kill math. They killed the &lt;em&gt;arithmetic grind&lt;/em&gt;. People who understood math got faster. People who never learned it just got confident wrong answers, faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The Vibe Coding Trap
&lt;/h2&gt;

&lt;p&gt;You've probably heard of "vibe coding": describe what you want, let AI write it, don't read the output, go with the feeling. And honestly? It's fun. It went from a joke to something a huge share of developers now use daily, and you can ship a working prototype in an afternoon.&lt;/p&gt;

&lt;p&gt;But look at what happens when the code breaks.&lt;/p&gt;

&lt;p&gt;I learned this the hard way. I once had an AI generate a chunk of a project that I didn't fully understand. It worked. I moved on. Then something small changed, it broke, and I had zero idea where to even start looking. I spent more time debugging code I never wrote than it would've taken to write it myself.&lt;/p&gt;

&lt;p&gt;The data backs this up. In Anthropic's own study of around 400,000 coding sessions, sessions rated as novice reached verified success about 15% of the time, versus roughly 28 to 33% for intermediate or expert sessions. That's vendor research, so take it as a signal, not gospel. But it lines up with what I see: &lt;strong&gt;AI makes experts faster. It doesn't turn beginners into experts.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And ask any working developer what annoys them most about AI code. In a Stack Overflow survey, the top frustration for about two-thirds of respondents was solutions that are "almost right". Almost right is the most dangerous kind of wrong. You only catch it if you understand what right looks like.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. What You Should Actually Learn
&lt;/h2&gt;

&lt;p&gt;If you're a beginner, stop trying to learn everything. Here's the short list that actually works.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. One language, properly
&lt;/h3&gt;

&lt;p&gt;Pick Python or JavaScript. Not both. Not five. Get to the point where you can write a small program from a blank file without copy-pasting. Fundamentals beat frameworks every time.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Debugging
&lt;/h3&gt;

&lt;p&gt;This is the new superpower. When AI gives you broken code, the person who can read an error message and trace the problem wins. Learn to use print statements, read stack traces, and Google (or ask AI) &lt;em&gt;specific&lt;/em&gt; questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Git and GitHub
&lt;/h3&gt;

&lt;p&gt;Every job expects this. Learn to commit, branch, and push. It's boring. Do it anyway. It's also your public proof that you build things.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Basic SQL and how data is stored
&lt;/h3&gt;

&lt;p&gt;Almost every app is a fancy wrapper around a database. If you understand tables, queries, and why things get slow, you're already ahead of most beginners.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Reading code
&lt;/h3&gt;

&lt;p&gt;Sounds weird, but most of your career is reading code someone else wrote. Now that includes code an AI wrote. Practice reading before you write.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Explaining what you built
&lt;/h3&gt;

&lt;p&gt;Being able to say "here's the problem, here's what I built, here's why I made this choice" is worth more than a fancy tech stack. Communication is the skill nobody puts on a roadmap.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. How to Use AI While Learning (Without Rotting Your Brain)
&lt;/h2&gt;

&lt;p&gt;I'm not telling you to avoid AI. That's silly, and employers expect you to use it. I'm telling you to use it like a &lt;em&gt;tutor&lt;/em&gt;, not a &lt;em&gt;vending machine&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here are the rules I follow and tell everyone in my club:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Try first, ask second.&lt;/strong&gt; Spend at least 15 minutes fighting the problem yourself. The struggle is where the learning actually happens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never paste code you can't explain.&lt;/strong&gt; If you can't explain a line out loud, you don't own it yet. Ask the AI to explain it like you're new, then explain it back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask it to quiz you.&lt;/strong&gt; "Give me 5 questions on this topic and don't show the answers until I try." This alone changes everything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Break it on purpose.&lt;/strong&gt; Take working code, change one thing, and predict what will break. If you can predict it, you understand it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask "why," not just "how."&lt;/strong&gt; The best prompt for a beginner isn't "write me a login system." It's "why do we hash passwords instead of encrypting them?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use AI to go &lt;em&gt;deeper&lt;/em&gt;, not to skip the work.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Build Proof, Not Tutorials
&lt;/h2&gt;

&lt;p&gt;Here's the honest hiring reality right now. Companies are picky. A certificate of completion won't cut it.&lt;/p&gt;

&lt;p&gt;What works instead is &lt;strong&gt;two or three real projects that are actually deployed&lt;/strong&gt; and solve a real problem. Not a to-do app copied from a tutorial. Something specific: a tool for your college, a small site for a local business, a bot that fixes an annoying thing in your daily life.&lt;/p&gt;

&lt;p&gt;Then do the part everyone skips: write a proper README explaining what it does, why you built it, and what you'd improve. If you used AI along the way, say how and where you checked its work. That's exactly the kind of maturity hiring managers want to see.&lt;/p&gt;

&lt;p&gt;And join something. A club, an open-source project, a Discord community. Being around people who build things keeps you honest and gets you noticed. Running our IT club taught me that most opportunities come from people who know you build stuff, not from cold applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Things I'd Tell My Younger Self
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Nobody is "too late." Every generation of developers thought the field was already crowded.&lt;/li&gt;
&lt;li&gt;Tutorial hell is real. If you've watched 40 hours and built nothing, stop watching.&lt;/li&gt;
&lt;li&gt;The goal isn't to write code faster than AI. It's to be the person who knows whether the code is &lt;em&gt;good&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Consistency beats intensity. One hour a day for six months beats a 12-hour weekend binge.&lt;/li&gt;
&lt;li&gt;Your first projects will be ugly. Ship them anyway.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  That's It. That's the Honest Take.
&lt;/h2&gt;

&lt;p&gt;Coding isn't dead. The lazy version of coding is. The version where you understand what you're building, can debug when things break, and use AI as a power tool instead of a crutch? That version is more valuable than ever.&lt;/p&gt;

&lt;p&gt;Now go close that "coding is dead" video and open your editor. Write something small. Break it. Fix it. Repeat.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's Connect
&lt;/h2&gt;

&lt;p&gt;I'm Prayush Adhikari, currently grinding through computer engineering, leading an IT club, and building my own company on the side. I write about Linux, productivity, and the honest side of being a developer.&lt;/p&gt;

&lt;p&gt;If this hit home, drop a comment and tell me where you're stuck right now. I read every one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;linkedin.com/in/adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;github.com/adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Portfolio: &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What's your biggest fear as a beginner right now: AI taking your job, or never getting your first one? Tell me, and I'll write the next post about it.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Sources for the numbers above:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;a href="https://daily.dev/blog/how-to-get-first-developer-job/" rel="noopener noreferrer"&gt;How to Get Your First Developer Job in 2026 (daily.dev)&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;a href="https://wavect.io/blog/vibe-coders-new-junior-developers/" rel="noopener noreferrer"&gt;Are Vibe Coders Replacing Junior Developers? (Wavect)&lt;/a&gt;, which covers the Stanford revision, the BLS projection, the Anthropic study, and the Stack Overflow survey&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>ai</category>
      <category>career</category>
      <category>programming</category>
    </item>
    <item>
      <title>Top 10 AI Coding Tools You Need in 2026 (Or You're Basically Coding With One Hand Tied Behind Your Back)</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Sun, 20 Sep 2026 20:02:48 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/top-10-ai-coding-tools-you-need-in-2026-or-youre-basically-coding-with-one-hand-tied-behind-your-272g</link>
      <guid>https://dev.to/adhikareeprayush/top-10-ai-coding-tools-you-need-in-2026-or-youre-basically-coding-with-one-hand-tied-behind-your-272g</guid>
      <description>&lt;p&gt;So here's the thing nobody warned us about: the "AI will help you code" era quietly turned into the "AI will just... code" era, and if you blinked you probably missed it. One day you're accepting autocomplete suggestions like a normal person, the next day your terminal is opening pull requests without you. Wild times. Anyway, here's ten tools that are actually worth your time right now, ranked by "how often do I personally open this."&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;strong&gt;Claude Code&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This one lives in your terminal and just... does things. Refactors, writes tests, reads your whole repo before making a suggestion instead of guessing from three open tabs like some tools I won't name. It feels less like autocomplete and more like handing a task to a very fast, slightly overcaffeinated junior dev who actually read the codebase first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://claude.com/product/claude-code" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;strong&gt;Cursor&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Cursor took "VS Code but the AI actually understands your project" and ran with it. Multi-file edits, chat that doesn't forget what file you're in, the whole deal. If you've been Copilot-only, this is the upgrade that makes you go "oh, we're doing THIS now."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cursor.com/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;strong&gt;GitHub Copilot Workspace&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Copilot grew up. It's not just finishing your sentences anymore — you can hand it an issue and it drafts an actual plan before touching code. Feels less like a suggestion box and more like a very eager teammate who reads tickets before Slacking you questions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/features/copilot" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. &lt;strong&gt;Windsurf&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The agentic-editor space got crowded fast, and Windsurf earned its spot by being genuinely good at holding context across a big session without you re-explaining your entire architecture every ten minutes. Underrated for long refactor sessions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://windsurf.com/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. &lt;strong&gt;v0 by Vercel&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Describe a UI, get actual working React components back. It's the closest thing to "type a sentence, get a webpage" that doesn't look like it was built in 2013. Frontend prototyping got stupidly fast.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://v0.dev/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. &lt;strong&gt;Qodo (formerly CodiumAI)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Test coverage is the vegetables of software development — you know you should, you usually don't. Qodo writes actually-relevant tests based on what your code does instead of generic boilerplate. Slightly less guilt at code review time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.qodo.ai/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. &lt;strong&gt;Tabnine&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For the "I like AI help but I'd also like my proprietary codebase to not leave the building" crowd. Local/private deployment options make it the pick for teams with strict data policies. Boring in the best way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.tabnine.com/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. &lt;strong&gt;Warp&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A terminal that understands natural language and has an AI baked directly in for command lookup and debugging weird shell errors. If you've ever googled "how to undo a git rebase" at 1am, this is for you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.warp.dev/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. &lt;strong&gt;Graphite&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Code review, but the AI actually summarizes the diff for your reviewers instead of them scrolling through 40 files going "sure, looks fine, ship it." Stacked PRs plus AI summaries make review way less of a chore.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://graphite.dev/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. &lt;strong&gt;Replit Agent&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Full apps from a prompt, deployed and running, no local setup required. It's the tool that makes non-devs go "wait, I could build this?" — which is either exciting or terrifying depending on your job security anxiety that day.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://replit.com/" rel="noopener noreferrer"&gt;Check It Out&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;The honest takeaway: nobody's job is "type code" anymore, it's "know what to ask for and whether the answer is actually good." Worth spending a weekend poking at two or three of these instead of doomscrolling about how AI is coming for your job. Pick one, break something small in a side project, learn from it.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>coding</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Security Pitfalls in React Apps I Learned the Hard Way</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Sat, 20 Jun 2026 15:05:53 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/security-pitfalls-in-react-apps-i-learned-the-hard-way-56e0</link>
      <guid>https://dev.to/adhikareeprayush/security-pitfalls-in-react-apps-i-learned-the-hard-way-56e0</guid>
      <description>&lt;p&gt;A few months back I was doing a code review for a friend's project and noticed they were storing JWTs in localStorage. I almost said nothing because honestly, I had done the same thing in like three projects before someone pointed it out to me. That's kind of the problem with frontend security. Nobody really teaches it properly, so we all just copy patterns from tutorials that were written to be quick, not safe.&lt;/p&gt;

&lt;p&gt;So here's what I've picked up, mostly from messing things up myself or catching bugs before they became actual incidents.&lt;/p&gt;

&lt;h2&gt;
  
  
  XSS is more common than you think
&lt;/h2&gt;

&lt;p&gt;Cross-Site Scripting is when attacker-controlled JavaScript ends up running in your user's browser. Sounds dramatic. It's also surprisingly easy to introduce by accident.&lt;/p&gt;

&lt;p&gt;The most common way I've seen it happen in React is through &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt;. Someone needs to render rich text from a CMS or a user comment, they google how to do it, find this prop, use it, and move on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;userInput&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;__html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userInput&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;userInput&lt;/code&gt; is coming from anything a user typed or any external source, this is a problem. An attacker can craft input that includes script tags and now that runs in every other user's browser that loads the comment.&lt;/p&gt;

&lt;p&gt;The fix is pretty straightforward. React escapes content by default when you render it normally, so just do that when you can:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;userInput&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;userInput&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And when you genuinely need to render HTML, run it through DOMPurify first. It strips out anything dangerous before it hits the DOM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;DOMPurify&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dompurify&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;userInput&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DOMPurify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sanitize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userInput&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;__html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;clean&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not perfect, but significantly better than nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSRF is the one people forget about entirely
&lt;/h2&gt;

&lt;p&gt;I genuinely forgot CSRF was a thing for a while. It doesn't come up much in React tutorials because the React part isn't really where the vulnerability lives.&lt;/p&gt;

&lt;p&gt;The short version: if your app uses cookies for auth, an attacker can get a logged-in user to make requests to your server from a completely different site. The browser sends the cookies automatically, your server sees a valid session, and whatever that request was supposed to do just... happens.&lt;/p&gt;

&lt;p&gt;The standard defenses are CSRF tokens (a secret value the attacker can't read from their site) and setting &lt;code&gt;SameSite=Strict&lt;/code&gt; or &lt;code&gt;SameSite=Lax&lt;/code&gt; on your cookies. The SameSite attribute alone cuts off most of these attacks without much extra work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Set-Cookie: session=abc123; SameSite=Strict; Secure; HttpOnly
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're using a backend framework, there's usually middleware that handles CSRF token generation and validation. Worth checking if it's actually enabled rather than assuming.&lt;/p&gt;

&lt;h2&gt;
  
  
  localStorage is fine until it isn't
&lt;/h2&gt;

&lt;p&gt;I know the feeling. Tutorial says put the JWT in localStorage, you put it in localStorage, app works, you ship it. And most of the time nothing bad happens.&lt;/p&gt;

&lt;p&gt;The issue is that localStorage is readable by any JavaScript running on the page. So if you ever end up with an XSS vulnerability (a bad npm package, a forgotten &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt;, whatever) the attacker's script can just read your token straight out of storage and send it somewhere.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;token&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// readable by literally any JS on this page&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HttpOnly cookies solve this because JavaScript can't read them at all. The browser sends them with requests automatically, but no script can access the value. The tradeoff is that your backend needs to set the cookie for you, which adds a bit of coordination. But if you're already building an API, it's not that much extra work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security headers exist and you're probably not sending them
&lt;/h2&gt;

&lt;p&gt;This took me embarrassingly long to actually implement. Security headers are HTTP response headers your server sends that tell the browser how to behave. Most apps don't send them because nobody ever runs into a direct error from not having them.&lt;/p&gt;

&lt;p&gt;Content Security Policy is the big one. It tells the browser which sources are allowed to load scripts, styles, images, etc. A solid CSP adds a meaningful second layer against XSS because even if a script gets injected, the browser may refuse to run it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Content-Security-Policy: default-src 'self'; script-src 'self'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's also &lt;code&gt;X-Content-Type-Options: nosniff&lt;/code&gt; which stops browsers from sniffing content types, and &lt;code&gt;X-Frame-Options: DENY&lt;/code&gt; which prevents your app from being iframed on other sites (relevant for clickjacking).&lt;/p&gt;

&lt;p&gt;If you're running an Express backend, the Helmet package sets most of these in a few lines. If you're on Vercel or Netlify, you can set them in a config file. Either way it's not a big lift once you actually sit down to do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accidentally shipping secret keys
&lt;/h2&gt;

&lt;p&gt;This one has bitten people I know. React apps bundle environment variables into the JavaScript that ships to the browser, which means anyone can open DevTools and read them.&lt;/p&gt;

&lt;p&gt;In Create React App, only variables prefixed with &lt;code&gt;REACT_APP_&lt;/code&gt; get included in the bundle. In Vite, it's &lt;code&gt;VITE_&lt;/code&gt;. The problem is people forget this rule and prefix something they shouldn't.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# now visible to anyone who opens the network tab&lt;/span&gt;
&lt;span class="nv"&gt;REACT_APP_STRIPE_SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sk_live_abc123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Secret keys belong on the server. If your frontend needs to charge a card, it should call your own API endpoint, which then calls Stripe using the secret key from a server-side environment variable. The frontend never needs to touch the key directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Honestly
&lt;/h2&gt;

&lt;p&gt;Most of this stuff isn't complicated once you know it exists. The gap is that nobody really lays it out together in one place during the "learn React" phase, so you end up shipping apps with several of these issues without realizing it.&lt;/p&gt;

&lt;p&gt;I'm still finding old projects of mine where I got lazy about some of this. If you're in the same boat, pick one thing from this list and fix it this week. That's usually how I approach it rather than trying to audit everything at once.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you've hit a security bug in production or caught one before it went out, I'd genuinely like to hear what it was in the comments.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Connect!
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>security</category>
      <category>programming</category>
    </item>
    <item>
      <title>I Built a Free Public Random Quotes API — No Key, No Auth, Just Use It</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Wed, 06 May 2026 16:44:54 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/i-built-a-free-public-random-quotes-api-no-key-no-auth-just-use-it-kg5</link>
      <guid>https://dev.to/adhikareeprayush/i-built-a-free-public-random-quotes-api-no-key-no-auth-just-use-it-kg5</guid>
      <description>&lt;p&gt;Hey there! So you've been Googling for a &lt;strong&gt;free quotes API&lt;/strong&gt; that doesn't require signing up, doesn't throttle you after 100 requests, and actually has useful filters?&lt;/p&gt;

&lt;p&gt;Yeah, I built that. It's live, it's public, and I want you to use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Base URL:&lt;/strong&gt; &lt;code&gt;https://quotesapi.prayushadhikari.com.np/api&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;No API key. No authentication. No credit card. Just copy the URL and start fetching quotes. Let me show you everything it can do.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Another Quotes API?
&lt;/h2&gt;

&lt;p&gt;Most &lt;strong&gt;random quotes APIs&lt;/strong&gt; I found while building projects were either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dead (domain expired, RIP)&lt;/li&gt;
&lt;li&gt;Rate-limited to the point of uselessness&lt;/li&gt;
&lt;li&gt;Behind a signup wall for basic features&lt;/li&gt;
&lt;li&gt;Returning the same 20 quotes forever&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I needed something with real filtering — by author, category, text search, quote length. So I built it. And since I built it anyway, I hosted it publicly so you don't have to.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try It Right Now
&lt;/h2&gt;

&lt;p&gt;Open your browser or terminal and hit this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes/random"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll get back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"quote"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"I feel bare. I didn't realize I wore my secrets as armor until they were gone and now everyone sees me as I really am."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Veronica Roth, Insurgent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"armor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"secrets"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"meta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;499708&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"offset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"order"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"random"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"returned"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice &lt;code&gt;category&lt;/code&gt; is an array — a single quote can belong to multiple categories. And yeah, &lt;code&gt;meta.total&lt;/code&gt; is 499,708. Nearly half a million quotes. That's not a typo.&lt;/p&gt;

&lt;p&gt;That's it. No setup, no tokens, no nonsense. It just works.&lt;/p&gt;




&lt;h2&gt;
  
  
  All Available Endpoints
&lt;/h2&gt;

&lt;p&gt;Hit the discovery endpoint first — it gives you the full route map:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what's available:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Route map — your starting point&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/quotes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Paginated quotes with all filters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/quotes/random&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Random quote(s), default &lt;code&gt;limit=1&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/categories&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All available categories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/authors&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Searchable author list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /api/health&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Load status + diagnostics&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  The Random Quotes Endpoint
&lt;/h2&gt;

&lt;p&gt;The most popular use case — &lt;strong&gt;get a random quote&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Single random quote (default)&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes/random"&lt;/span&gt;

&lt;span class="c"&gt;# 5 random quotes at once&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes/random?limit=5"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is what you want for daily quote widgets, Discord bots, browser extensions, email footers — anything that needs a surprise every time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Filters That Actually Work
&lt;/h2&gt;

&lt;p&gt;This is where this &lt;strong&gt;free quotes API&lt;/strong&gt; beats most alternatives. You're not stuck with just "give me random." Let me show you what's possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Filter by Category
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Quotes about wisdom&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?category=wisdom&amp;amp;limit=5"&lt;/span&gt;

&lt;span class="c"&gt;# Multiple categories (OR — matches either)&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?categories=wisdom,motivation&amp;amp;limit=10"&lt;/span&gt;

&lt;span class="c"&gt;# Multiple categories (AND — must match all)&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?categories=wisdom,motivation&amp;amp;match_categories=all"&lt;/span&gt;

&lt;span class="c"&gt;# Exclude a category&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?exclude_category=politics&amp;amp;limit=10"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Filter by Author
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Partial match, case-insensitive&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?author=oscar&amp;amp;limit=5"&lt;/span&gt;

&lt;span class="c"&gt;# Exact match&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?author_exact=Oscar%20Wilde"&lt;/span&gt;

&lt;span class="c"&gt;# Exclude specific author&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?exclude_author=Napoleon&amp;amp;limit=10"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Full-Text Search
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search inside quote text&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?q=journey&amp;amp;order=text&amp;amp;limit=20"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Quote Length Filters
&lt;/h3&gt;

&lt;p&gt;Perfect when you have a UI constraint — like a widget that only fits a tweet-length quote:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Short quotes only (under 100 characters)&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?max_len=100&amp;amp;limit=5"&lt;/span&gt;

&lt;span class="c"&gt;# Medium length range&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?min_len=80&amp;amp;max_len=200&amp;amp;limit=5"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Discover What's in the Dataset
&lt;/h2&gt;

&lt;p&gt;Before you build filters, explore what categories and authors exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# All categories&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/categories"&lt;/span&gt;

&lt;span class="c"&gt;# Categories with quote counts&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/categories?counts=true"&lt;/span&gt;

&lt;span class="c"&gt;# Search authors by name&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/authors?q=einstein&amp;amp;limit=10"&lt;/span&gt;

&lt;span class="c"&gt;# All authors (up to 100)&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/authors"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;counts=true&lt;/code&gt; on categories returns &lt;code&gt;{ name, count }[]&lt;/code&gt; which is exactly what you need to build a category picker UI.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Seed Param — My Favorite Feature
&lt;/h2&gt;

&lt;p&gt;This is the most underrated param in this &lt;strong&gt;random quotes API&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?order=random&amp;amp;seed=42&amp;amp;limit=10"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same seed = same "random" order, every single time. Use cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Daily quote of the day&lt;/strong&gt; — use today's date as the seed (&lt;code&gt;seed=20250506&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shareable quote lists&lt;/strong&gt; — send someone a seed and they see what you see&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reproducible testing&lt;/strong&gt; — no flaky randomness in your test suite&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Pagination for the Full Dataset
&lt;/h2&gt;

&lt;p&gt;Random order doesn't support &lt;code&gt;offset&lt;/code&gt; — that's intentional. But if you switch to deterministic ordering, pagination works perfectly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Page 1&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?order=text&amp;amp;limit=20&amp;amp;offset=0"&lt;/span&gt;

&lt;span class="c"&gt;# Page 2&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/quotes?order=text&amp;amp;limit=20&amp;amp;offset=20"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;meta&lt;/code&gt; field in every response gives you &lt;code&gt;total&lt;/code&gt; and &lt;code&gt;returned&lt;/code&gt; so you can compute pages on your end.&lt;/p&gt;




&lt;h2&gt;
  
  
  Using the API in JavaScript
&lt;/h2&gt;

&lt;p&gt;This &lt;strong&gt;quotes API&lt;/strong&gt; supports CORS, so you can call it directly from the browser — no backend needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Fetch a single random quote&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getRandomQuote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://quotesapi.prayushadhikari.com.np/api/quotes/random&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Fetch quotes by category&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getQuotesByCategory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;limit&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://quotesapi.prayushadhikari.com.np/api/quotes?&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;meta&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;quotes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Daily quote using date as seed&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getDailyQuote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toISOString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/-/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;random&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://quotesapi.prayushadhikari.com.np/api/quotes?&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Example usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;quote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getRandomQuote&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;" — &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Using It in Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;

&lt;span class="n"&gt;BASE_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://quotesapi.prayushadhikari.com.np/api&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_random_quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;limit&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;category&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;category&lt;/span&gt;

    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BASE_URL&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/quotes/random&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;data&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_daily_quote&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;seed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;today&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%Y%m%d&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BASE_URL&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/quotes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;order&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;random&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;seed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;limit&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;data&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Get a random motivation quote
&lt;/span&gt;&lt;span class="n"&gt;quotes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_random_quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;motivation&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;quotes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quote&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; — &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;author&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get today's quote (same every time you call it today)
&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_daily_quote&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Daily: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;daily&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quote&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  All Query Parameters at a Glance
&lt;/h2&gt;

&lt;p&gt;Here's the full reference for &lt;code&gt;GET /api/quotes&lt;/code&gt; and &lt;code&gt;GET /api/quotes/random&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameter&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;author&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Substring match on author name&lt;/td&gt;
&lt;td&gt;&lt;code&gt;author=einstein&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;author_exact&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exact author name&lt;/td&gt;
&lt;td&gt;&lt;code&gt;author_exact=Albert%20Einstein&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;exclude_author&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exclude this author&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exclude_author=Napoleon&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;category&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Must include this category&lt;/td&gt;
&lt;td&gt;&lt;code&gt;category=wisdom&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;categories&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Comma-separated, OR logic&lt;/td&gt;
&lt;td&gt;&lt;code&gt;categories=wisdom,love&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;match_categories=all&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Require ALL listed categories&lt;/td&gt;
&lt;td&gt;&lt;code&gt;match_categories=all&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;exclude_category&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exclude this category&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exclude_category=politics&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;q&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Substring search in quote text&lt;/td&gt;
&lt;td&gt;&lt;code&gt;q=courage&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;min_len&lt;/code&gt; / &lt;code&gt;max_len&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Quote character length range&lt;/td&gt;
&lt;td&gt;&lt;code&gt;min_len=50&amp;amp;max_len=200&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;limit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Results per page (default 10, max 100)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;limit=25&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;offset&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pagination offset (not for random)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;offset=40&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;order&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;random&lt;/code&gt;, &lt;code&gt;author&lt;/code&gt;, &lt;code&gt;text&lt;/code&gt;, &lt;code&gt;none&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;order=author&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;seed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deterministic shuffle for random&lt;/td&gt;
&lt;td&gt;&lt;code&gt;seed=42&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;legacy=true&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns bare JSON array&lt;/td&gt;
&lt;td&gt;&lt;code&gt;legacy=true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;meta=false&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Omit meta object from response&lt;/td&gt;
&lt;td&gt;&lt;code&gt;meta=false&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  What Can You Build With This?
&lt;/h2&gt;

&lt;p&gt;Here's what I'd love to see people building:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Daily quote bots&lt;/strong&gt; for Discord, Telegram, or Slack&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New tab browser extensions&lt;/strong&gt; with category-filtered quotes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Motivational widgets&lt;/strong&gt; on personal portfolio sites&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quote-of-the-day email newsletters&lt;/strong&gt; using the seed param&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile apps&lt;/strong&gt; that match quote moods to user input&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Screensaver or wallpaper generators&lt;/strong&gt; with random quotes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Obsidian plugins&lt;/strong&gt; that pull quotes into your daily notes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CLI tools&lt;/strong&gt; that show a quote on every terminal open&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The API handles &lt;strong&gt;CORS&lt;/strong&gt; for all GET requests, so browser-direct calls work without a proxy backend.&lt;/p&gt;




&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Getting empty &lt;code&gt;data: []&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hit the health endpoint first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://quotesapi.prayushadhikari.com.np/api/health"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It'll tell you if the full dataset loaded correctly or if there's a fallback in use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filters returning fewer results than expected?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might be combining too many strict filters. Try loosening them one at a time. The &lt;code&gt;q&lt;/code&gt; text search is a substring match, so &lt;code&gt;q=inspiration&lt;/code&gt; won't match a quote containing "inspire."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Need ALL quotes, not just 10?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;order=text&lt;/code&gt; (or &lt;code&gt;order=author&lt;/code&gt;) with &lt;code&gt;offset&lt;/code&gt; for pagination. &lt;code&gt;meta.total&lt;/code&gt; tells you how many exist total. Don't use &lt;code&gt;order=random&lt;/code&gt; with &lt;code&gt;offset&lt;/code&gt; — it won't work.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;I built this &lt;strong&gt;free random quotes API&lt;/strong&gt; because I was tired of hitting dead endpoints and rate limits every time I wanted to add a quote feature to a side project. Now you don't have to be.&lt;/p&gt;

&lt;p&gt;It's free. It's public. It's not going anywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start here:&lt;/strong&gt; &lt;code&gt;https://quotesapi.prayushadhikari.com.np/api&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Drop a comment with what you're building — I read every single one and it helps me figure out what to add next. Want me to cover setting up your own instance, adding new quote datasets, or building a Discord bot with this? Let me know.&lt;/p&gt;

&lt;p&gt;I'm &lt;strong&gt;Prayush Adhikari&lt;/strong&gt;, grinding through computer engineering and shipping things in public.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now go fetch some quotes.&lt;/p&gt;

</description>
      <category>api</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>MongoDB: Zero to Advanced (The Real Guide Nobody Else Will Write)</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Tue, 24 Feb 2026 08:14:10 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/mongodb-zero-to-advanced-the-real-guide-nobody-else-will-write-em5</link>
      <guid>https://dev.to/adhikareeprayush/mongodb-zero-to-advanced-the-real-guide-nobody-else-will-write-em5</guid>
      <description>&lt;p&gt;Hey there! So you've heard about MongoDB and now you're wondering what the heck it actually is and why everyone keeps talking about it. I've been down this rabbit hole and I'm going to save you from the confusion, the bad tutorials, and the Stack Overflow rabbit holes.&lt;/p&gt;

&lt;p&gt;This is the guide I wish existed when I started.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's Talk About Databases First (Bear With Me)
&lt;/h2&gt;

&lt;p&gt;Before we jump into MongoDB, we need to talk about what a database actually is. And no, I'm not going to give you the boring textbook definition.&lt;/p&gt;

&lt;p&gt;Think of it this way: you're building a web app. You have users, their profiles, their posts, their comments. Where does all this data live when you close your laptop? Not in your code. Not in RAM. It lives in a &lt;strong&gt;database&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A database is just an organized way to store, retrieve, and manage data. That's it. No magic.&lt;/p&gt;

&lt;p&gt;Now here's where it gets interesting. There are two main types of databases and understanding the difference is going to save you a LOT of confusion.&lt;/p&gt;

&lt;h3&gt;
  
  
  SQL vs NoSQL: The Fight That Never Ends
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;SQL databases&lt;/strong&gt; (PostgreSQL, MySQL, SQLite) are like super strict spreadsheets. You define the columns upfront, every row must follow the same structure, and everything is neatly organized in tables. Want to change the structure? Hope you like writing migration scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NoSQL databases&lt;/strong&gt; (MongoDB being the king here) are more like a folder full of documents. Each document can look completely different from the others. Some can have 5 fields, some can have 50. Nobody's going to yell at you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3kr2pwtcgfqntyn3z1b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3kr2pwtcgfqntyn3z1b.png" alt=" " width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So when should you use MongoDB? Here's my honest take:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You're building a modern web or mobile app&lt;/li&gt;
&lt;li&gt;Your data structure might change a lot (early stage projects)&lt;/li&gt;
&lt;li&gt;You need to store nested or complex data (like a user profile with embedded addresses and preferences)&lt;/li&gt;
&lt;li&gt;You want to move fast without worrying about schema migrations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When should you NOT use MongoDB? If you're dealing with super complex relationships and need a lot of joins (think banking systems, ERPs), a relational database might serve you better. MongoDB added transactions and lookup operations, but SQL databases still shine there.&lt;/p&gt;




&lt;h2&gt;
  
  
  Setting Up MongoDB (The Easy Way)
&lt;/h2&gt;

&lt;p&gt;Forget local installation for now. Seriously. The number of people who've given up on MongoDB because of installation headaches is criminal.&lt;/p&gt;

&lt;p&gt;We're using &lt;strong&gt;MongoDB Atlas&lt;/strong&gt; — it's free, it's cloud-based, and it's exactly what real companies use in production.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create Your Atlas Account
&lt;/h3&gt;

&lt;p&gt;Head to &lt;a href="https://www.mongodb.com/products/platform/atlas-database" rel="noopener noreferrer"&gt;mongodb.com/products/platform/atlas-database&lt;/a&gt; and sign up. It's free. No credit card needed for the free tier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcro05r5fnym76r3owj9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcro05r5fnym76r3owj9k.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create Your First Cluster
&lt;/h3&gt;

&lt;p&gt;Once you're in, click &lt;strong&gt;"Build a Database"&lt;/strong&gt; and choose the &lt;strong&gt;M0 Free&lt;/strong&gt; option. Pick whichever cloud provider and region is closest to you. Name your cluster whatever you want — I usually just call it &lt;code&gt;MyCluster&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4lwz6uwwxkt5w7tb59w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4lwz6uwwxkt5w7tb59w.png" alt=" " width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Set Up Access
&lt;/h3&gt;

&lt;p&gt;Atlas will ask you to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a database user (username + password — save these!)&lt;/li&gt;
&lt;li&gt;Your current IP address will be added as the part of auto setup process. (If not head to Database and Network access menu from sidebar you will find the way)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Get Your Connection String
&lt;/h3&gt;

&lt;p&gt;Click &lt;strong&gt;Connect&lt;/strong&gt; on your cluster → &lt;strong&gt;Connect using MongoDB Compass&lt;/strong&gt; or &lt;strong&gt;Connect your application&lt;/strong&gt;. Copy that connection string. You'll need it later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Install MongoDB Compass
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.mongodb.com/products/compass" rel="noopener noreferrer"&gt;MongoDB Compass&lt;/a&gt; is the GUI for MongoDB. It lets you visually browse your data, run queries, and manage collections without writing a single line of code. This is your new best friend.&lt;/p&gt;

&lt;p&gt;Download it, install it, paste your connection string, and hit connect. You're in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqjmt9w0lyqvwkh2v60q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqjmt9w0lyqvwkh2v60q.png" alt=" " width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Core Concepts: The Building Blocks
&lt;/h2&gt;

&lt;p&gt;Alright, let's get into the actual meat of MongoDB. There are 4 things you need to understand before anything else makes sense.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Database
&lt;/h3&gt;

&lt;p&gt;A database in MongoDB is exactly what it sounds like — a container for your data. Think of it like a project folder. If you're building a blog app, you'd probably have a &lt;code&gt;blog&lt;/code&gt; database.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Collection
&lt;/h3&gt;

&lt;p&gt;A collection is like a table in SQL — except it has no fixed structure. It holds a bunch of documents. In your &lt;code&gt;blog&lt;/code&gt; database, you might have a &lt;code&gt;posts&lt;/code&gt; collection and a &lt;code&gt;users&lt;/code&gt; collection.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Document
&lt;/h3&gt;

&lt;p&gt;This is where MongoDB gets cool. A document is a single record — like a row in SQL — but it's stored as &lt;strong&gt;JSON-like format called BSON&lt;/strong&gt;. It looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"64f3a1b2c3d4e5f6a7b8c9d0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Prayush Adhikari"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"prayush@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"skills"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"JavaScript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MongoDB"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Linux"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Kathmandu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Nepal"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See that? An array inside a document. An object inside a document. This flexibility is what makes MongoDB powerful.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;code&gt;_id&lt;/code&gt; Field
&lt;/h3&gt;

&lt;p&gt;Every document in MongoDB gets a unique &lt;code&gt;_id&lt;/code&gt; field automatically. MongoDB generates it as an &lt;strong&gt;ObjectId&lt;/strong&gt; unless you provide your own. It looks ugly but it's your document's unique fingerprint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjp8tlgrq7m4wo4bubii4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjp8tlgrq7m4wo4bubii4.png" alt=" " width="800" height="764"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  CRUD Operations: The Heart of Everything
&lt;/h2&gt;

&lt;p&gt;CRUD stands for &lt;strong&gt;Create, Read, Update, Delete&lt;/strong&gt;. If you master these four operations, you can build basically anything with MongoDB.&lt;/p&gt;

&lt;p&gt;I'll show you both the shell commands (&lt;code&gt;mongosh&lt;/code&gt;) and what they look like in Compass so you get the full picture. First create a database and a collection using the gui. I am creating the database named &lt;code&gt;myDatabase&lt;/code&gt; and collection named &lt;code&gt;users&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create: Adding Data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// use the created database&lt;/span&gt;
&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;myDatabase&lt;/span&gt;

&lt;span class="c1"&gt;// Insert a single document&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;prayush@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;joined&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Insert multiple documents at once&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertMany&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alice@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bob@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukhaekqy0mgwzh7losks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukhaekqy0mgwzh7losks.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Read: Finding Data
&lt;/h3&gt;

&lt;p&gt;This is where you'll spend most of your time, so pay attention.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Find ALL documents in a collection&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;// Find documents that match a condition&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Find one specific document&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;prayush@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Find users older than 20&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Find users and only return name and email (projection)&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Sort by age ascending&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Limit to 5 results&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those &lt;code&gt;$gt&lt;/code&gt;, &lt;code&gt;$lt&lt;/code&gt;, &lt;code&gt;$gte&lt;/code&gt; things are called &lt;strong&gt;query operators&lt;/strong&gt; and they're incredibly powerful. Here's a quick cheat sheet:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$gt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{ age: { $gt: 18 } }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$lt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less than&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{ age: { $lt: 65 } }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$gte&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than or equal&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{ age: { $gte: 21 } }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$lte&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less than or equal&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{ score: { $lte: 100 } }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$ne&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Not equal&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{ status: { $ne: "banned" } }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$in&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;In an array of values&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{ role: { $in: ["admin", "mod"] } }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3sxc12gdfka5a89vnpo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3sxc12gdfka5a89vnpo.png" alt=" " width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Update: Changing Data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Update ONE document&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;          &lt;span class="c1"&gt;// Filter: find this document&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$set&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;         &lt;span class="c1"&gt;// What to change&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Update MULTIPLE documents&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;updateMany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$lt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$set&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;minor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Increment a value&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$inc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;loginCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;// Adds 1 to loginCount&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Add item to an array&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$push&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Docker&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;$set&lt;/code&gt;, &lt;code&gt;$inc&lt;/code&gt;, &lt;code&gt;$push&lt;/code&gt; are called &lt;strong&gt;update operators&lt;/strong&gt;. NEVER update a document without using these operators — if you skip them, you'll overwrite the entire document and lose all your data. Ask me how I know.&lt;/p&gt;

&lt;h3&gt;
  
  
  Delete: Removing Data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Delete ONE document&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deleteOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Delete MULTIPLE documents&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deleteMany&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$lt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Delete ALL documents in a collection (use carefully!)&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deleteMany&lt;/span&gt;&lt;span class="p"&gt;({})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffevrdvt4n6j8vor2jcjh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffevrdvt4n6j8vor2jcjh.png" alt=" " width="800" height="285"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Data Modeling: The Part That Actually Matters
&lt;/h2&gt;

&lt;p&gt;Here's the thing nobody tells beginners — getting your data model right is more important than knowing all the fancy MongoDB features. A bad data model will haunt you for the entire life of your project.&lt;/p&gt;

&lt;p&gt;In MongoDB, you have two ways to relate data: &lt;strong&gt;embedding&lt;/strong&gt; and &lt;strong&gt;referencing&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Embedding (Nesting Data Inside a Document)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Prayush"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"street"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"123 Kathmandu St"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Kathmandu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"zip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"44600"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"orders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"item"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Keyboard"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"item"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Mouse"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use embedding when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The embedded data is always accessed with the parent (you always need the address when you get the user)&lt;/li&gt;
&lt;li&gt;The embedded data doesn't change often&lt;/li&gt;
&lt;li&gt;The array won't grow unboundedly (don't embed 10,000 comments in a blog post)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Referencing (Like Foreign Keys in SQL)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;users&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;collection&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Prayush"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;posts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;collection&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"post456"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"My MongoDB Guide"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"authorId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user123"&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;References&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;user&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use referencing when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The data is frequently updated independently&lt;/li&gt;
&lt;li&gt;The data is shared across many documents&lt;/li&gt;
&lt;li&gt;The array could grow very large&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjf0ug43ew7pl9i0043h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjf0ug43ew7pl9i0043h.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My rule of thumb: &lt;strong&gt;embed for read-heavy relationships, reference for write-heavy or large growing relationships.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Intermediate Queries: Leveling Up
&lt;/h2&gt;

&lt;p&gt;Now that you know the basics, let's get into some more powerful queries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Querying Arrays
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Find users who have "MongoDB" in their skills array&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MongoDB&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Find users who have BOTH "MongoDB" AND "JavaScript"&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$all&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MongoDB&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JavaScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Find users where at least one skill matches a condition&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; 
  &lt;span class="na"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$eq&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Docker&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Querying Nested/Embedded Documents
&lt;/h3&gt;

&lt;p&gt;Use dot notation to query inside nested objects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Find users in Kathmandu&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;address.city&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kathmandu&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Find orders over $100 within user documents&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;orders.price&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Logical Operators
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// AND: find users who are 21 AND from Kathmandu&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; 
  &lt;span class="na"&gt;$and&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;address.city&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kathmandu&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// OR: find users who are admins OR moderators&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;$or&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;moderator&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// NOT: find users who are NOT banned&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$not&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$eq&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banned&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Aggregation Framework: Where the Real Magic Happens
&lt;/h2&gt;

&lt;p&gt;This is the part that separates beginners from intermediate developers. The aggregation framework lets you process and transform your data through a &lt;strong&gt;pipeline&lt;/strong&gt; of stages.&lt;/p&gt;

&lt;p&gt;Think of it like a factory assembly line — your data goes in one end, gets processed at each stage, and comes out transformed on the other end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;aggregate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="c1"&gt;// Stage 1: Filter (like find)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;completed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="c1"&gt;// Stage 2: Group by category and sum revenue&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$category&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;totalRevenue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$sum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$price&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;orderCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$sum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}},&lt;/span&gt;

  &lt;span class="c1"&gt;// Stage 3: Sort by revenue descending&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$sort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;totalRevenue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="c1"&gt;// Stage 4: Only return top 5&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pipeline would give you the top 5 product categories by revenue. Try doing that with just &lt;code&gt;find()&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Aggregation Stages
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$match&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Filter documents (like &lt;code&gt;find&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$group&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Group documents and compute values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$sort&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sort results&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$project&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Include/exclude/transform fields&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$limit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cap the number of results&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$unwind&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deconstruct an array into separate documents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$lookup&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Join with another collection&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Real Example: Blog Stats
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Get total posts and average views per author&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;aggregate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$authorId&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;totalPosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$sum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;avgViews&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$avg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$views&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;totalViews&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$sum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$views&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$sort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;totalViews&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feao762d0yk4xdn088l96.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feao762d0yk4xdn088l96.png" alt=" " width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Indexing: Making Your Database Fast
&lt;/h2&gt;

&lt;p&gt;Here's a fact: without indexes, MongoDB scans EVERY document in a collection to find matches. That's fine when you have 100 documents. It's catastrophic when you have 10 million.&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;index&lt;/strong&gt; is like the index at the back of a textbook — instead of reading every page to find "MongoDB," you look at the index, get the page number, and jump straight there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create an index on the email field&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;   &lt;span class="c1"&gt;// 1 = ascending, -1 = descending&lt;/span&gt;

&lt;span class="c1"&gt;// Create a compound index (on multiple fields)&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Create a unique index (no duplicate emails!)&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Check existing indexes&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getIndexes&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;// See how MongoDB executes a query (is it using an index?)&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;prayush@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;explain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;executionStats&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to Add an Index
&lt;/h3&gt;

&lt;p&gt;Add indexes on fields that you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Query frequently (filters, search)&lt;/li&gt;
&lt;li&gt;Sort on often&lt;/li&gt;
&lt;li&gt;Use in joins/lookups&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't add indexes on everything — they take up space and slow down writes. Index what you query. That's the rule.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfm5q33wfrtvxokxjeof.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfm5q33wfrtvxokxjeof.png" alt=" " width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Transactions: When You Need ACID Guarantees
&lt;/h2&gt;

&lt;p&gt;Here's something that surprises a lot of people: MongoDB supports multi-document transactions since version 4.0. Yes, the same kind of transactions you get in PostgreSQL.&lt;/p&gt;

&lt;p&gt;This matters when you need multiple operations to either ALL succeed or ALL fail. Classic example: transferring money between two accounts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startTransaction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;accounts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$inc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;accounts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$inc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commitTransaction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Transfer successful!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abortTransaction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Transfer failed. Rolled back.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the second update fails, the first one is automatically rolled back. No partial transfers. No corrupted data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Connecting MongoDB to Node.js (Let's Build Something Real)
&lt;/h2&gt;

&lt;p&gt;Theory is cool but let's actually use this thing. Here's how to connect MongoDB to a Node.js app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;mongo-demo &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;mongo-demo
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;mongodb dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MONGODB_URI=your_connection_string_from_atlas
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic Connection
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// db.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MongoClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongodb&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;connectDB&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MONGODB_URI&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Connected to MongoDB!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;connectDB&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Building a Simple CRUD API
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;connectDB&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./db&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;connectDB&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;db&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blogDB&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;posts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// CREATE&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newPost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My First Post&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MongoDB is actually pretty cool&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;views&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mongodb&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tutorial&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Created:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newPost&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;insertedId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// READ&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allPosts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Posts:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;allPosts&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// UPDATE&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;updateOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;newPost&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;insertedId&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$inc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;views&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// DELETE&lt;/span&gt;
  &lt;span class="c1"&gt;// await posts.deleteOne({ _id: newPost.insertedId });&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxfq8bgmkv2angox26a08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxfq8bgmkv2angox26a08.png" alt=" " width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Mongoose: The Better Way to Use MongoDB with Node.js
&lt;/h2&gt;

&lt;p&gt;If you're building a real app with Node.js, you'll want to use &lt;strong&gt;Mongoose&lt;/strong&gt; instead of the raw MongoDB driver. Mongoose adds schema validation, middleware, and a bunch of quality-of-life features.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;mongoose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongoose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Define a schema&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;postSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;views&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Create a model&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Post&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;postSchema&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Connect and use&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MONGODB_URI&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Create&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mongoose is Great&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Schema validation saves lives&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;// Find&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Prayush&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;disconnect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The big win with Mongoose? If you try to save a document without a required field, it throws an error before it even hits the database. That's validation at the schema level.&lt;/p&gt;




&lt;h2&gt;
  
  
  Atlas Search and Vector Search: The 2025-2026 Stuff
&lt;/h2&gt;

&lt;p&gt;This is where MongoDB gets genuinely exciting for modern applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Atlas Search
&lt;/h3&gt;

&lt;p&gt;Built on Apache Lucene, Atlas Search lets you add full-text search to your app without spinning up a separate Elasticsearch instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Full-text search on posts&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;aggregate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$search&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mongodb tutorial&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Vector Search (For AI Apps)
&lt;/h3&gt;

&lt;p&gt;If you're building RAG applications or any AI-powered feature that needs semantic search, MongoDB Atlas Vector Search is a game changer. You store embeddings (vectors from AI models) right alongside your data and query by similarity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Search for semantically similar documents&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;aggregate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;$vectorSearch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vector_index&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;embedding&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;queryVector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...],&lt;/span&gt;  &lt;span class="c1"&gt;// Your query embedding&lt;/span&gt;
      &lt;span class="na"&gt;numCandidates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the technology that powers modern AI chatbots that can "remember" things from documents. MongoDB lets you build this without stitching together 5 different services.&lt;/p&gt;




&lt;h2&gt;
  
  
  Time Series Collections (MongoDB 8.x)
&lt;/h2&gt;

&lt;p&gt;Got IoT data? Logs? Metrics? MongoDB 8.x introduced optimized time series collections that store time-based data WAY more efficiently than regular collections.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create a time series collection&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createCollection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sensorData&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;timeseries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;timeField&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;timestamp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;metaField&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sensorId&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;granularity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;seconds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Insert time series data&lt;/span&gt;
&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sensorData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertMany&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="na"&gt;sensorId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sensor1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;23.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;humidity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="na"&gt;sensorId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sensor2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;25.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;humidity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;55&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;MongoDB automatically handles compression and optimized storage for you. This stuff used to require specialized databases like InfluxDB. Now MongoDB handles it natively.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Secret to MongoDB Mastery
&lt;/h2&gt;

&lt;p&gt;Here's what nobody tells you: knowing all the commands is the easy part. The hard part is &lt;strong&gt;knowing which tool to reach for&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Every concept I've covered comes down to one question: what is the most efficient way to store and retrieve THIS specific data for THIS specific use case?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Embedding vs referencing is a design decision, not a rule.&lt;/li&gt;
&lt;li&gt;Indexes are solutions to performance problems, not defaults you add to everything.&lt;/li&gt;
&lt;li&gt;Aggregations are for analytics and transformations, not for basic reads.&lt;/li&gt;
&lt;li&gt;Transactions are for when correctness absolutely cannot be compromised.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start building something. A blog. A todo app. A movie tracker. Break it. Fix it. Look at your slow queries. Add indexes. Refactor your data model when it starts hurting. That's how you actually learn MongoDB.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Here are some things I'd cover in separate deep dives if you want me to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full REST API with Express + MongoDB&lt;/strong&gt; — Let's build it properly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication system with MongoDB&lt;/strong&gt; — JWT, sessions, the whole thing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sharding and scaling&lt;/strong&gt; — When your app hits a million users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MongoDB Change Streams&lt;/strong&gt; — Real-time notifications without polling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Atlas Triggers and Functions&lt;/strong&gt; — Serverless functions that react to database events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drop a comment with which one you want first and I'll get to it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's Connect
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Prayush Adhikari&lt;/strong&gt;, grinding through computer engineering and writing content that actually helps. If this guide saved you from a bad tutorial or a confusing Stack Overflow thread, we're even.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What do you want me to cover next? Drop it in the comments.&lt;/p&gt;

&lt;p&gt;Now go build something with MongoDB.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>mongodb</category>
      <category>database</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>Database Indexing Explained Like You're 5 (Then Like You're a Senior Dev)</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Wed, 12 Nov 2025 19:51:22 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/database-indexing-explained-like-youre-5-then-like-youre-a-senior-dev-57hc</link>
      <guid>https://dev.to/adhikareeprayush/database-indexing-explained-like-youre-5-then-like-youre-a-senior-dev-57hc</guid>
      <description>&lt;p&gt;Hey there! So you want to understand database indexing? Cool. Let me break this down in a way that actually makes sense, starting from the absolute basics and working our way up to the stuff that'll make you look like a genius in your next code review.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 5-Year-Old Explanation
&lt;/h2&gt;

&lt;p&gt;Imagine you have a massive book with 10,000 pages about different animals. No table of contents, no organization, just random animals on random pages.&lt;/p&gt;

&lt;p&gt;Now, your teacher asks: "Find me information about elephants."&lt;/p&gt;

&lt;p&gt;What do you do? You flip through every single page until you find elephants. Page 1, nope. Page 2, nope. Page 3, nope... this is going to take forever, right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's your database without indexes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now imagine the same book, but at the front, there's a special page that says:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Elephants: Page 4,521&lt;/li&gt;
&lt;li&gt;Lions: Page 892&lt;/li&gt;
&lt;li&gt;Penguins: Page 7,234&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Boom. You jump straight to page 4,521. Found it in seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's an index.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Simple, right? Now let's get into the real stuff.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Real World Problem
&lt;/h2&gt;

&lt;p&gt;Let's say you're building an app. Could be anything, a blog, an e-commerce site, whatever. You've got a users table with 1 million records. Someone tries to log in, and you run this query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'prayush@example.com'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without an index, your database does what's called a &lt;strong&gt;full table scan&lt;/strong&gt;. It literally checks every single one of those 1 million rows. Every. Single. One.&lt;/p&gt;

&lt;p&gt;On my machine, that query took &lt;strong&gt;2.3 seconds&lt;/strong&gt; without an index.&lt;/p&gt;

&lt;p&gt;With an index? &lt;strong&gt;0.003 seconds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Yeah, you read that right. From 2.3 seconds to 3 milliseconds. That's not just fast, that's "your users don't rage-quit your app" fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Indexes Actually Work (Getting Technical)
&lt;/h2&gt;

&lt;p&gt;Alright, now we're getting into the good stuff. Let's talk about what's really happening under the hood.&lt;/p&gt;

&lt;h3&gt;
  
  
  The B-Tree Structure
&lt;/h3&gt;

&lt;p&gt;Most databases use something called a B-Tree (Balanced Tree) for indexes. And no, despite what everyone thinks, the B doesn't stand for "binary." It actually stands for "balanced" or possibly "Bayer" (the guy who invented it).&lt;/p&gt;

&lt;p&gt;Here's the deal: a B-Tree organizes your data in a tree structure where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The root node contains pointers to other nodes&lt;/li&gt;
&lt;li&gt;Intermediate nodes contain more pointers&lt;/li&gt;
&lt;li&gt;Leaf nodes contain the actual data (or pointers to the actual data)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you search for something, the database traverses this tree. Instead of checking 1 million rows, it might only need to check 3-4 nodes to find what it's looking for.&lt;/p&gt;

&lt;p&gt;Let me show you what I mean with a real example from a project I worked on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Creating a simple users table&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;SERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="nb"&gt;TIMESTAMP&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- Insert a million records (not showing the full script here, trust me)&lt;/span&gt;
&lt;span class="c1"&gt;-- Now let's see the difference&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;EXPLAIN&lt;/span&gt; &lt;span class="k"&gt;ANALYZE&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'random@email.com'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;-- Seq Scan on users (cost=0.00..25833.00 rows=1 width=89) (actual time=2347.921..2347.922 rows=1 loops=1)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_users_email&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;EXPLAIN&lt;/span&gt; &lt;span class="k"&gt;ANALYZE&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'random@email.com'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;-- Index Scan using idx_users_email on users (cost=0.42..8.44 rows=1 width=89) (actual time=0.038..0.039 rows=1 loops=1)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The numbers don't lie. The cost dropped from 25833 to 8.44. That's massive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Indexes (Because One Size Doesn't Fit All)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Single Column Index
&lt;/h3&gt;

&lt;p&gt;The basic one we've been talking about:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_email&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this when you're frequently searching by a single column.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Composite Index
&lt;/h3&gt;

&lt;p&gt;Multiple columns in one index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_email_username&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's where it gets interesting. The &lt;strong&gt;order matters&lt;/strong&gt;. This index is great for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'x'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'y'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;-- Fast&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'x'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;-- Also fast&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'y'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;-- Slow! Doesn't use the index&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why? Because the index is organized by email first, then username. It's like a phone book sorted by last name, then first name. You can't efficiently find someone by just their first name.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Unique Index
&lt;/h3&gt;

&lt;p&gt;Enforces uniqueness AND speeds up queries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;UNIQUE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_unique_email&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Perfect for emails, usernames, or anything that should be unique.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Partial Index
&lt;/h3&gt;

&lt;p&gt;This one's cool. Index only part of your data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_active_users&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;is_active&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you only ever query active users, why index the inactive ones? Save space, save time.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Full-Text Index
&lt;/h3&gt;

&lt;p&gt;For searching text content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_post_content&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="k"&gt;USING&lt;/span&gt; &lt;span class="n"&gt;GIN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_tsvector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'english'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is what makes your blog search actually work. I use this on my own projects and it's a game changer for search functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Dark Side: When Indexes Hurt You
&lt;/h2&gt;

&lt;p&gt;Here's what nobody tells beginners: indexes aren't free. They come with a cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage Cost
&lt;/h3&gt;

&lt;p&gt;Every index is basically a copy of your data in a different structure. More indexes = more disk space. I learned this the hard way when my database size doubled because I got index-happy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Write Performance
&lt;/h3&gt;

&lt;p&gt;Every time you INSERT, UPDATE, or DELETE, the database has to update all your indexes too.&lt;/p&gt;

&lt;p&gt;Real talk: I once had a table with 12 indexes. Inserts were taking forever. Dropped it down to 4 strategic indexes, and suddenly my batch inserts went from 5 minutes to 30 seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Wrong Index Is Worse Than No Index
&lt;/h3&gt;

&lt;p&gt;True story: I once created an index on a column with only 3 possible values (status: pending, active, inactive). The database was spending more time maintaining and reading the index than it would have just scanning the table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule of thumb:&lt;/strong&gt; If a column has low cardinality (not many unique values), skip the index.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Indexing Mistakes (Learn from My Pain)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Mistake 1: Indexing Everything
&lt;/h3&gt;

&lt;p&gt;I did this. You'll probably do this too. Don't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt; Index based on your actual queries. Use EXPLAIN ANALYZE to see what's slow, then index specifically for that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 2: Ignoring Index Order in Composite Indexes
&lt;/h3&gt;

&lt;p&gt;Remember that email + username example? Put the most selective column first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Bad: username has duplicates, email is unique&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_bad&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- Good: email is unique, username has duplicates  &lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_good&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mistake 3: Not Analyzing Your Indexes
&lt;/h3&gt;

&lt;p&gt;Indexes can get bloated over time. In PostgreSQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;REINDEX&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I do this monthly on my production databases. Keeps things running smooth.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 4: Forgetting About Covering Indexes
&lt;/h3&gt;

&lt;p&gt;If your query only needs data that's in the index, the database doesn't even need to touch the main table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_covering&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- This query only touches the index, super fast&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'x'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mistake 5: Over-Optimizing Too Early
&lt;/h3&gt;

&lt;p&gt;I wasted weeks optimizing queries that ran once a day on 1000 rows. Focus on what matters: frequent queries on large tables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced Strategies (Senior Dev Territory)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Strategy 1: Index-Only Scans
&lt;/h3&gt;

&lt;p&gt;Structure your indexes so queries can be answered without touching the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_posts_covering&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- This query is lightning fast&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Strategy 2: Conditional Indexes with Expressions
&lt;/h3&gt;

&lt;p&gt;You can index the result of a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_lower_email&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;LOWER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;-- Now this is fast&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;LOWER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'prayush@example.com'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Strategy 3: Index Hints (Use Sparingly)
&lt;/h3&gt;

&lt;p&gt;Sometimes the query planner gets it wrong. In MySQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="n"&gt;USE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idx_email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'x'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But honestly, if you need hints, you probably need better indexes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Strategy 4: Monitoring Index Usage
&lt;/h3&gt;

&lt;p&gt;Find unused indexes and kill them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- PostgreSQL&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;schemaname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tablename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indexname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx_scan&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pg_stat_user_indexes&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;idx_scan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I do this every month. Found 15 unused indexes once. Dropped them all, freed up 2GB of space.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Example: My Blog Optimization
&lt;/h2&gt;

&lt;p&gt;Let me show you something from an actual project. I have a blog posts table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;SERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="nb"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="nb"&gt;TIMESTAMP&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="nb"&gt;TIMESTAMP&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initial problem: Homepage query was taking 800ms to load recent posts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'published'&lt;/span&gt; 
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt; 
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;My indexing solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Partial index for published posts only&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_published_posts&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'published'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- For author pages&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_author_posts&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'published'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- For full-text search&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_post_search&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt; 
&lt;span class="k"&gt;USING&lt;/span&gt; &lt;span class="n"&gt;GIN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_tsvector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'english'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Homepage: 800ms → 12ms&lt;/li&gt;
&lt;li&gt;Author pages: 450ms → 8ms&lt;/li&gt;
&lt;li&gt;Search: Actually works now (was timing out before)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Three strategic indexes. Not twelve random ones. That's the key.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Practical Checklist
&lt;/h2&gt;

&lt;p&gt;Here's what I do for every new table:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Primary key gets an index automatically&lt;/strong&gt; (don't create one manually)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Foreign keys ALWAYS get indexed&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;idx_posts_user_id&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Columns in WHERE clauses get indexed&lt;/strong&gt; (if the query runs often)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Columns in ORDER BY get indexed&lt;/strong&gt; (especially with LIMIT)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run EXPLAIN ANALYZE on slow queries&lt;/strong&gt; before creating indexes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor index usage monthly&lt;/strong&gt; and drop the dead ones&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Tools I Actually Use
&lt;/h2&gt;

&lt;h3&gt;
  
  
  pgAdmin
&lt;/h3&gt;

&lt;p&gt;For PostgreSQL, pgAdmin's query analyzer is solid. Shows you exactly what's happening.&lt;/p&gt;

&lt;h3&gt;
  
  
  MySQL Workbench
&lt;/h3&gt;

&lt;p&gt;Same thing for MySQL. The visual EXPLAIN is chef's kiss.&lt;/p&gt;

&lt;h3&gt;
  
  
  Database Monitoring
&lt;/h3&gt;

&lt;p&gt;I run a self-hosted Grafana dashboard that tracks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Query execution times&lt;/li&gt;
&lt;li&gt;Index usage stats&lt;/li&gt;
&lt;li&gt;Table scan counts&lt;/li&gt;
&lt;li&gt;Cache hit ratios&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Want a tutorial on setting this up? Let me know because monitoring is half the battle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bottom Line
&lt;/h2&gt;

&lt;p&gt;Indexing isn't rocket science, but it's not something you can just wing either. Here's the real strategy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start without indexes (except primary keys and foreign keys)&lt;/li&gt;
&lt;li&gt;Build your app, collect real usage data&lt;/li&gt;
&lt;li&gt;Find the slow queries (EXPLAIN ANALYZE is your friend)&lt;/li&gt;
&lt;li&gt;Add indexes strategically&lt;/li&gt;
&lt;li&gt;Monitor and adjust&lt;/li&gt;
&lt;li&gt;Don't over-optimize early&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And remember: the best index is the one that solves a real performance problem. Not the one that looks cool in your schema.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's Connect
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Prayush Adhikari&lt;/strong&gt;, grinding through computer engineering and breaking down complex topics into actually useful content. If database performance gets you excited (or frustrated), you're in the right place.&lt;/p&gt;

&lt;p&gt;Got questions? Want me to cover something specific about databases? Drop a comment. I read every single one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next up, I'm thinking about diving into database sharding or maybe query optimization techniques. What would you rather read about? Let me know.&lt;/p&gt;

&lt;p&gt;Now go index something. But not everything.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>beginners</category>
      <category>database</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Setting Up Your Command Line Assistant with Google Services (The Complete Guide)</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Tue, 04 Nov 2025 07:27:06 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/setting-up-your-command-line-assistant-with-google-services-the-complete-guide-3000</link>
      <guid>https://dev.to/adhikareeprayush/setting-up-your-command-line-assistant-with-google-services-the-complete-guide-3000</guid>
      <description>&lt;p&gt;Hey there! Welcome back. It's been a minute since my last blog on &lt;a href="https://dev.to/adhikareeprayush/7-productivity-hacks-that-changed-my-life-and-will-change-yours-too-19ne"&gt;7 Productivity Hacks That Changed My Life&lt;/a&gt;. Remember hack number 3? The wild command line assistant that manages your entire Google workspace from the terminal?&lt;/p&gt;

&lt;p&gt;Yeah, that one blew up in the comments. Everyone wanted the full breakdown. So here it is, the complete no-BS guide to setting up your own command line assistant with access to Gmail, Google Drive, Calendar, and basically your entire Google ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Setup is Absolutely Insane
&lt;/h2&gt;

&lt;p&gt;Before we dive in, let me paint you a picture of what your life looks like once this is running:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Send emails&lt;/strong&gt; without ever opening a browser&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Schedule meetings&lt;/strong&gt; with a single command&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upload files to Drive&lt;/strong&gt; from your terminal&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search your Gmail&lt;/strong&gt; like you're querying a database&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manage calendar events&lt;/strong&gt; faster than you can say "productivity"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the best part? It's all happening in your terminal. No clicking. No switching windows. Just pure, efficient command-line magic.&lt;/p&gt;

&lt;h2&gt;
  
  
  What You'll Need (The Boring But Necessary Stuff)
&lt;/h2&gt;

&lt;p&gt;Look, I'm not gonna sugarcoat it. You need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A computer (obviously)&lt;/li&gt;
&lt;li&gt;Stable internet connection (wild requirement in 2024, I know)&lt;/li&gt;
&lt;li&gt;Basic familiarity with terminal/command line&lt;/li&gt;
&lt;li&gt;A Google account&lt;/li&gt;
&lt;li&gt;About 30-45 minutes to set this up properly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One-time setup, lifetime benefits. Let's go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Install Gemini CLI (And Why Version Matters)
&lt;/h2&gt;

&lt;p&gt;Here's where most people mess up. You can't just install the latest version and call it a day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Gemini CLI?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Simple. It integrates seamlessly with Google Apps Script, giving us a robust MCP (Model Context Protocol) server for our command line agent. The integration is chef's kiss level smooth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Version Trap:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I spent hours debugging before I figured this out. You MUST use version &lt;strong&gt;0.1.12&lt;/strong&gt;. The latest versions? Broken. Buggy. Frustrating.&lt;/p&gt;

&lt;p&gt;Save yourself the headache and install the specific version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @google/generative-ai-cli@0.1.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify it installed correctly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;0.1.12&lt;/code&gt;. If not, uninstall and try again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Set Up Google Cloud Console (The Foundation)
&lt;/h2&gt;

&lt;p&gt;This is crucial. Don't skip this step or you'll run into permission issues later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Your Project:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Head over to &lt;a href="https://console.cloud.google.com" rel="noopener noreferrer"&gt;Google Cloud Console&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"New Project"&lt;/strong&gt; in the top dropdown&lt;/li&gt;
&lt;li&gt;Name it something memorable (I called mine "CLI-Assistant")&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Enable the APIs:
&lt;/h3&gt;

&lt;p&gt;You need to enable these APIs for your project:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;"APIs &amp;amp; Services"&lt;/strong&gt; &amp;gt; &lt;strong&gt;"Library"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Search and enable each of these:

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Gmail API&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Google Drive API&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Google Calendar API&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Docs API&lt;/strong&gt; (optional but recommended)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Sheets API&lt;/strong&gt; (optional but recommended)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Generate Your Gemini API Key:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In the Cloud Console, go to &lt;strong&gt;"APIs &amp;amp; Services"&lt;/strong&gt; &amp;gt; &lt;strong&gt;"Credentials"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Create Credentials"&lt;/strong&gt; &amp;gt; &lt;strong&gt;"API Key"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Copy this key somewhere safe (you'll need it multiple times)&lt;/li&gt;
&lt;li&gt;(Optional but recommended) Click &lt;strong&gt;"Restrict Key"&lt;/strong&gt; and limit it to only the APIs you enabled&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pro tip: Keep this key private. Like, seriously private.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Create Your Google Apps Script
&lt;/h2&gt;

&lt;p&gt;Time to build the brain of the operation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set Up the Project:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://script.google.com" rel="noopener noreferrer"&gt;script.google.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"New Project"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Name it something like "MCP Server for CLI"&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Write the Code.gs File:
&lt;/h3&gt;

&lt;p&gt;Delete the default code and paste this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YOUR_GEMINI_API_KEY_HERE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;doPost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;eventObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ToolsForMCPServer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Enable the tools you want to use&lt;/span&gt;
  &lt;span class="c1"&gt;// Play around with these flags&lt;/span&gt;
  &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enableBaseTools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enableClassroomTools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enablePeopleTools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enableAnalyticsTools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enableMapsTools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;eventObject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getServer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MCPApp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mcpApp&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;accessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sample&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setServices&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;LockService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getScriptLock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;server&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Replace&lt;/strong&gt; &lt;code&gt;YOUR_GEMINI_API_KEY_HERE&lt;/code&gt; with the API key you generated earlier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About those flags:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;enableBaseTools&lt;/code&gt;: This is the core. Gmail, Drive, Calendar. Keep this &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The others are specialized. Enable them if you need Classroom, Analytics, or Maps integration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create the appsscript.json File:
&lt;/h3&gt;

&lt;p&gt;This is where permissions live. It's critical.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your Apps Script project, click &lt;strong&gt;"Project Settings"&lt;/strong&gt; (gear icon)&lt;/li&gt;
&lt;li&gt;Check &lt;strong&gt;"Show 'appsscript.json' manifest file in editor"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Go back to the editor, you'll see &lt;code&gt;appsscript.json&lt;/code&gt; appear&lt;/li&gt;
&lt;li&gt;Replace its contents with this:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"timeZone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"YOUR_TIMEZONE_HERE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;e.g.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;America/Los_Angeles&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"exceptionLogging"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"STACKDRIVER"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"runtimeVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"V8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"enabledAdvancedServices"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"userSymbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Drive"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"serviceId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"drive"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"v3"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"userSymbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Gmail"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"serviceId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"gmail"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"userSymbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Calendar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"v3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"serviceId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"calendar"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"libraries"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"userSymbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MCPApp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"libraryId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1TlX_L9COAriBlAYvrMLiRFQ5WVf1n0jChB6zHamq2TNwuSbVlI5sBUzh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"18"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"userSymbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ToolsForMCPServer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"libraryId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1lnE7UL1jQgPDbTB9yjhiwZM0SaS9MObhzvWUWb_t8FisO6A3bLepvM2j"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"39"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"webapp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"executeAs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"USER_DEPLOYING"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"access"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ANYONE_ANONYMOUS"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"oauthScopes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/gmail.modify"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/gmail.send"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/drive"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/drive.file"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/calendar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/calendar.events"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/spreadsheets"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/documents"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/presentations"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/forms"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"https://www.googleapis.com/auth/script.external_request"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change &lt;code&gt;timeZone&lt;/code&gt; to your timezone&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;oauthScopes&lt;/code&gt; are the permissions. This setup requests access to Gmail, Drive, Calendar, Docs, Sheets, etc.&lt;/li&gt;
&lt;li&gt;The libraries (&lt;code&gt;MCPApp&lt;/code&gt; and &lt;code&gt;ToolsForMCPServer&lt;/code&gt;) are essential. Don't change these IDs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Save everything (Ctrl+S or Cmd+S).&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Deploy Your Script
&lt;/h2&gt;

&lt;p&gt;This is where your code becomes accessible.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In Apps Script, click &lt;strong&gt;"Deploy"&lt;/strong&gt; &amp;gt; &lt;strong&gt;"New deployment"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click the gear icon next to "Select type"&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;"Web app"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Fill in the details:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: "MCP Server v1" (or whatever you want)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execute as&lt;/strong&gt;: "Me"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who has access&lt;/strong&gt;: "Anyone"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Deploy"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorize the app&lt;/strong&gt; (Google will ask you to review permissions)

&lt;ul&gt;
&lt;li&gt;Click &lt;strong&gt;"Review Permissions"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Choose your Google account&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Advanced"&lt;/strong&gt; (if it says the app is unverified)&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Go to &lt;a href="https://dev.tounsafe"&gt;your project name&lt;/a&gt;"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Allow"&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;Web App URL&lt;/strong&gt; that appears. It looks like: &lt;code&gt;https://script.google.com/macros/s/SOME_LONG_ID/exec&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep this URL handy. You're almost there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Configure Gemini CLI to Use Your MCP Server
&lt;/h2&gt;

&lt;p&gt;Now we connect everything together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initialize Gemini CLI:
&lt;/h3&gt;

&lt;p&gt;Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the prompts to set up your Gemini API key if you haven't already.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add the MCP Server:
&lt;/h3&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once Gemini CLI starts, type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This opens the MCP configuration menu. Follow the interactive prompts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose &lt;strong&gt;"Add new MCP server"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Enter a name: &lt;code&gt;google-services&lt;/code&gt; (or whatever you prefer)&lt;/li&gt;
&lt;li&gt;Paste your &lt;strong&gt;Web App URL&lt;/strong&gt; from Step 4&lt;/li&gt;
&lt;li&gt;Confirm the configuration&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Test the Connection:
&lt;/h3&gt;

&lt;p&gt;Try a simple command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Check my latest emails
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What's on my calendar today?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it works, you'll see Gemini accessing your Google services and returning results. If not, double-check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your API key is correct in Code.gs&lt;/li&gt;
&lt;li&gt;The Web App URL is correct&lt;/li&gt;
&lt;li&gt;You authorized the script properly&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 6: Start Living in the Future
&lt;/h2&gt;

&lt;p&gt;You're done. Seriously. Now you can:&lt;/p&gt;

&lt;h3&gt;
  
  
  Send Emails:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Send an email to john@example.com with subject "Meeting Tomorrow" and body "Hey John, are we still on for 3pm?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Schedule Meetings:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a calendar event for tomorrow at 2pm titled "Team Standup"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Gmail:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Find all emails from boss@company.com from last week
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Upload to Drive:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Upload document.pdf to my Google Drive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  And So Much More
&lt;/h3&gt;

&lt;p&gt;The possibilities are endless. The more you use it, the more you'll discover what's possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pro Tips and Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Common Issues:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"Permission denied" errors:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go back to your Apps Script and re-deploy with fresh permissions&lt;/li&gt;
&lt;li&gt;Make sure all APIs are enabled in Google Cloud Console&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;"Version mismatch" errors:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Confirm you're using gemini-cli version 0.1.12&lt;/li&gt;
&lt;li&gt;Uninstall and reinstall if needed: &lt;code&gt;npm uninstall -g @google/generative-ai-cli &amp;amp;&amp;amp; npm install -g @google/generative-ai-cli@0.1.12&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;MCP server not responding:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check your Web App URL is correct&lt;/li&gt;
&lt;li&gt;Make sure the deployment is set to "Anyone" access&lt;/li&gt;
&lt;li&gt;Verify your API key is valid&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Make It Better:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Customize the flags&lt;/strong&gt; in Code.gs based on what you actually use&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add more oauth scopes&lt;/strong&gt; if you need access to other Google services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create aliases&lt;/strong&gt; in your shell for common commands&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Experiment&lt;/strong&gt; with different prompts to see what works best&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Real Impact
&lt;/h2&gt;

&lt;p&gt;Here's what changed for me after setting this up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I send emails 5x faster&lt;/li&gt;
&lt;li&gt;Scheduling meetings takes seconds instead of minutes&lt;/li&gt;
&lt;li&gt;I never lose track of files because I can search Drive from anywhere&lt;/li&gt;
&lt;li&gt;My workflow is completely keyboard-driven (no more mouse clicking through UIs)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's not just about speed. It's about staying in flow. When you can do everything from the terminal, you're not context-switching. Your brain stays focused. That's the real productivity boost.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Want me to dive deeper into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Custom automation workflows&lt;/strong&gt; with this setup?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced MCP server configurations&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrating other services&lt;/strong&gt; beyond Google?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drop a comment and let me know what you want to see next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Connect
&lt;/h2&gt;

&lt;p&gt;I'm Prayush Adhikari, computer engineering student and productivity nerd. I'm documenting my journey of building systems that actually work.&lt;/p&gt;

&lt;p&gt;If this guide helped you (or if you got stuck somewhere), let's connect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt;: &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drop a comment below with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which part of the setup you found most useful&lt;/li&gt;
&lt;li&gt;What you're automating first&lt;/li&gt;
&lt;li&gt;What guide you want next&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading! Now go build something that makes your life easier.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;P.S. If you're stuck on any step, drop a comment. I read and respond to everything.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>automation</category>
      <category>tutorial</category>
      <category>productivity</category>
      <category>ai</category>
    </item>
    <item>
      <title>7 Productivity Hacks That Changed My Life (And Will Change Yours Too)</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Wed, 15 Oct 2025 08:19:43 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/7-productivity-hacks-that-changed-my-life-and-will-change-yours-too-19ne</link>
      <guid>https://dev.to/adhikareeprayush/7-productivity-hacks-that-changed-my-life-and-will-change-yours-too-19ne</guid>
      <description>&lt;p&gt;Hey there! I am glad you ended up here. Look, I've tried every productivity hack under the sun, and most of them? Complete garbage. But the ones I'm about to share? These actually work. And I'm using them right now as I write this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Talk About Productivity (The Real Deal)
&lt;/h2&gt;

&lt;p&gt;I like to be productive and who doesn't? But wtf is productivity in the first place? &lt;/p&gt;

&lt;p&gt;Here's the thing most people get wrong: productivity isn't about grinding 16 hours a day or having 47 tabs open while pretending to multitask. It's about &lt;strong&gt;doing things more efficiently&lt;/strong&gt; or better yet, &lt;strong&gt;doing repetitive things more efficiently&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And no, efficiency isn't just speed. It's about finding the best approach to get the best possible result. Sometimes that means slowing down to automate something that'll save you hours later.&lt;/p&gt;

&lt;p&gt;Since we have gone through some of the basics, lets dive into the actual hacks that have transformed how I work.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hacks That Actually Matter
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Ditch Chrome, Seriously
&lt;/h3&gt;

&lt;p&gt;One of the unavoidable things in our life is a web browser. We're constantly living in our browsers when we're online. I have tried almost all the web browsers out there and have finally settled on one that doesn't make me want to throw my laptop out the window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enter Vivaldi.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yeah yeah, it eats 2-3gb of RAM like it's nothing, but hear me out. If your computer has 16gb+ RAM or you're already using Chrome (which is basically a RAM black hole), you need to try this.&lt;/p&gt;

&lt;p&gt;Why Vivaldi slaps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's chromium based so all your favorite extensions work&lt;/li&gt;
&lt;li&gt;Mouse gestures that make you feel like a wizard&lt;/li&gt;
&lt;li&gt;Keyboard shortcuts for literally everything&lt;/li&gt;
&lt;li&gt;Multiple workspaces to keep your 600 tabs organized&lt;/li&gt;
&lt;li&gt;Themes that don't look like they're from 2010&lt;/li&gt;
&lt;li&gt;Zero bugs in my experience (and I push software to its limits)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The customization is insane. You can make it look and work exactly how your brain operates. And that's the key to productivity, working with tools that match your workflow, not against it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Automate Your Social Media Like a Boss
&lt;/h3&gt;

&lt;p&gt;Social medias like Discord and Telegram are goldmines for automation. And no, you don't need to be a coding wizard to make this happen.&lt;/p&gt;

&lt;p&gt;I've been running self-hosted n8n on my VPS and it's changed the game. Here's what I've built:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stream Suggester&lt;/strong&gt; - Because decision fatigue is real&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gemini in Telegram&lt;/strong&gt; - My AI buddy on the go&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Techy&lt;/strong&gt; - Sends me tech news from multiple RSS feeds automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The best part? You set it up once and forget about it. While everyone else is manually checking feeds and posting updates, you're three steps ahead.&lt;/p&gt;

&lt;p&gt;Want me to drop a full tutorial on setting up n8n locally or on a VPS? Drop a comment and let me know because this deserves its own deep dive.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Command Line Assistant (This One's Wild)
&lt;/h3&gt;

&lt;p&gt;Alright, here the things go pure wild. I have a command line assistant that basically runs my digital life. I'm talking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating Google meetings with a single command&lt;/li&gt;
&lt;li&gt;Adding calendar events instantly&lt;/li&gt;
&lt;li&gt;Scanning my Gmail for important stuff&lt;/li&gt;
&lt;li&gt;Sending emails without opening a browser&lt;/li&gt;
&lt;li&gt;Managing all Google services from the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This setup is chef's kiss level productivity. Here's the quick rundown:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Setup (Simplified):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install gemini-cli (the MCP server integration is smooth)&lt;/li&gt;
&lt;li&gt;Create a Google Apps Script (hit me up if you want my exact script)&lt;/li&gt;
&lt;li&gt;Configure Google Cloud Console permissions&lt;/li&gt;
&lt;li&gt;Grab your Gemini API key&lt;/li&gt;
&lt;li&gt;Authorize and boom, you're living in the future&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This needs its own blog because the full process is meaty, but trust me, once you have this running, you'll feel like Tony Stark.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Your IDE Matters More Than You Think
&lt;/h3&gt;

&lt;p&gt;Hot take: Your code editor can make or break your productivity.&lt;/p&gt;

&lt;p&gt;I use &lt;strong&gt;Neovim&lt;/strong&gt; and yes, I know what you're thinking. "Oh great, another Neovim evangelist." But hear me out.&lt;/p&gt;

&lt;p&gt;I felt the exact same way when people recommended it to me. Thought they were just trying to be elitist. But after customizing it with the right plugins, I'm never going back.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real talk though:&lt;/strong&gt; Don't just jump into Neovim cold turkey. Use &lt;strong&gt;VS Code AND Neovim&lt;/strong&gt; side by side at first. Slowly transition when you're comfortable. The learning curve is real, but the productivity gains are worth it.&lt;/p&gt;

&lt;p&gt;Want a Neovim setup tutorial? Let me know and I'll break down my entire config.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Build Your Second Brain
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Obsidian&lt;/strong&gt; has changed how I think.&lt;/p&gt;

&lt;p&gt;No, seriously. Having all your knowledge in one searchable, linked system is like having superpowers. And the best part? It's completely free if you set up sync yourself (I wrote a whole blog about this).&lt;/p&gt;

&lt;p&gt;Why Obsidian wins:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Massive community plugins&lt;/li&gt;
&lt;li&gt;Works on all devices&lt;/li&gt;
&lt;li&gt;Free sync if you're smart about it&lt;/li&gt;
&lt;li&gt;Everything is markdown (lightweight and future-proof)&lt;/li&gt;
&lt;li&gt;Themes that don't hurt your eyes&lt;/li&gt;
&lt;li&gt;Integration with everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your brain isn't meant to remember everything. It's meant to make connections. Let Obsidian handle the storage, you handle the thinking.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Your Terminal Shouldn't Suck
&lt;/h3&gt;

&lt;p&gt;One of the biggest headaches was my terminal. I wanted it to look cool, suggest past commands, and generally not feel like I time-traveled to 1995.&lt;/p&gt;

&lt;p&gt;Solution? &lt;strong&gt;Zsh with oh-my-zsh.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The productivity boost is subtle but massive. Auto-suggestions, better history, plugins for days, and honestly, when your terminal looks good, you want to use it more. And the more comfortable you are in the terminal, the more powerful you become.&lt;/p&gt;

&lt;p&gt;It has surely helped me become more productive without even realizing how much I've improved at command line.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Make The Switch to Linux (Yes, Really)
&lt;/h3&gt;

&lt;p&gt;I would highly recommend all of you to switch to Linux on your personal computers. And no, I'm not one of those "I use Arch btw" people (okay maybe a little).&lt;/p&gt;

&lt;p&gt;Here's why Windows is holding you back:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Less secure by design&lt;/li&gt;
&lt;li&gt;Bloated with stuff you'll never use&lt;/li&gt;
&lt;li&gt;Ads in the START MENU (seriously Microsoft?)&lt;/li&gt;
&lt;li&gt;Limited customization&lt;/li&gt;
&lt;li&gt;Constant forced updates at the worst times&lt;/li&gt;
&lt;li&gt;You don't actually own your OS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linux gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complete control&lt;/li&gt;
&lt;li&gt;No bloat&lt;/li&gt;
&lt;li&gt;Better security&lt;/li&gt;
&lt;li&gt;Customization freedom&lt;/li&gt;
&lt;li&gt;Better performance&lt;/li&gt;
&lt;li&gt;Actually free (as in freedom)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Need help choosing a distro? Want a full guide on making the switch? Drop a comment. I can write a whole series on this.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Real Secret
&lt;/h2&gt;

&lt;p&gt;Here's what nobody tells you about productivity: it's not about the tools. It's about designing systems that work FOR you, not against you.&lt;/p&gt;

&lt;p&gt;Every hack I've shared comes down to one thing: removing friction. The less mental energy you spend on repetitive tasks, the more you have for what actually matters.&lt;/p&gt;

&lt;p&gt;So start with one hack. Just one. Get it working. Then move to the next. Don't try to overhaul your entire workflow overnight because that's how you end up productive for exactly two days before burning out.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's Connect
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Prayush Adhikari&lt;/strong&gt;, currently grinding through computer engineering and building my online presence one blog at a time. I'm bringing more content like tutorials, deep dives, and honest takes on tech.&lt;/p&gt;

&lt;p&gt;If this helped you (or if you think I'm completely wrong about something), let's connect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drop a comment below with which hack you're trying first&lt;/li&gt;
&lt;li&gt;Follow me for more content that actually helps&lt;/li&gt;
&lt;li&gt;Share this if you know someone stuck in productivity hell&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Connect with me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linkedin: &lt;a href="https://linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Github: &lt;a href="https://github.com/adhikareeprayush" rel="noopener noreferrer"&gt;adhikareeprayush&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What productivity hack should I cover next? Let me know in the comments.&lt;/p&gt;

&lt;p&gt;Thanks for reading! Now go automate something.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>linux</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Stop Paying for Obsidian Sync: Here's How I Actually Did It</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Mon, 06 Oct 2025 19:26:04 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/stop-paying-for-obsidian-sync-heres-how-i-actually-did-it-3i4h</link>
      <guid>https://dev.to/adhikareeprayush/stop-paying-for-obsidian-sync-heres-how-i-actually-did-it-3i4h</guid>
      <description>&lt;p&gt;So you've fallen into the Obsidian rabbit hole. Good. Now you're realizing that having your notes on just one device is annoying as hell, and Obsidian wants $10/month to fix that problem. &lt;/p&gt;

&lt;p&gt;I get it—the devs deserve support, they built something genuinely useful. But I'm also not about to pay a subscription for syncing &lt;em&gt;text files&lt;/em&gt;. Yes, I said it. That's all your vault is. A bunch of &lt;code&gt;.md&lt;/code&gt; files sitting in a folder. &lt;/p&gt;

&lt;p&gt;So I rolled my own sync setup with Syncthing-Fork, and it's been running flawlessly across my laptop, phone, and a VPS for months. Zero cost, zero drama. Let me show you how.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Beauty of Obsidian: It's Just Files
&lt;/h2&gt;

&lt;p&gt;Here's why this works at all: Obsidian doesn't trap your data in some proprietary hellscape. Your vault is literally just a folder on your filesystem. Open it. Look at it. Those are markdown files. You could edit them in Notepad if you wanted to punish yourself.&lt;/p&gt;

&lt;p&gt;This isn't revolutionary—it's how software &lt;em&gt;should&lt;/em&gt; work. But in 2025, when every app wants to be a SaaS product with your data held hostage on their servers, Obsidian's approach feels almost rebellious.&lt;/p&gt;

&lt;p&gt;No database. No API calls to authenticate your right to access your own thoughts. Just files and folders, like it's 1995 and we still believed in owning our data.&lt;/p&gt;

&lt;p&gt;Which means if you can sync a folder, you can sync your entire Obsidian vault. And you absolutely can sync a folder without giving someone money every month.&lt;/p&gt;

&lt;h2&gt;
  
  
  Syncthing-Fork: The Unsexy Solution That Actually Works
&lt;/h2&gt;

&lt;p&gt;Syncthing is that rare piece of software that does one thing, does it well, and doesn't try to upsell you on AI features or premium tiers. It's open source, peer-to-peer, and once you set it up, you genuinely forget it exists.&lt;/p&gt;

&lt;p&gt;Syncthing-Fork is the Android variant that actually gets maintained.&lt;/p&gt;

&lt;p&gt;What sold me: I edit a note on my phone at 2 AM because my brain won't shut up. By the time I walk to my desk in the morning, that note is already on my laptop. No sync button. No "waiting for upload." It just &lt;em&gt;is&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The whole thing runs device-to-device. Encrypted. No cloud middleman harvesting your data to train their next AI model.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Setup: Three Devices Playing Nice
&lt;/h2&gt;

&lt;p&gt;I'm running this across:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Laptop&lt;/strong&gt; (Arch BTW)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Android phone&lt;/strong&gt; (Syncthing-Fork from Nickola Hristov)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VPS&lt;/strong&gt; (Docker container, always online)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The VPS is technically optional. But here's the thing: if my laptop's off and I change something on my phone, the VPS catches it immediately. Then when my laptop wakes up, it syncs from the VPS. It's basically a relay that ensures changes never get stuck in limbo. I am also planning to use static site generator out of &lt;code&gt;.md&lt;/code&gt; files for future so it will be helpful ig.&lt;/p&gt;

&lt;p&gt;Plus it's an automatic off-site backup. My laptop could spontaneously combust and my vault's still sitting on that VPS.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Actually Set This Up
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Making Syncthing Run Without Thinking About It
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Laptop&lt;/strong&gt;: Installed Syncthing, made it a systemd service so it starts on boot. I never want to manually start this thing. If I have to remember to run it, I'll forget, and then I'll have sync conflicts. Automate or die.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VPS&lt;/strong&gt;: Spun up a Docker container. Wrote a basic &lt;code&gt;docker-compose.yml&lt;/code&gt;, ran it, forgot about it. Docker handles restarts, keeps it isolated, makes updates trivial. The VPS isn't doing anything else demanding—it's just sitting there being reliable, which is what servers are actually for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phone&lt;/strong&gt;: Installed Syncthing-Fork, gave it the permissions it was crying about, set it to auto-start. Battery impact is negligible. We're syncing text, not mining crypto.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Connection Dance
&lt;/h3&gt;

&lt;p&gt;Every Syncthing instance has a device ID. I added all three devices to each other. Think of it like exchanging SSH keys, except it's actually user-friendly.&lt;/p&gt;

&lt;p&gt;Then I pointed Syncthing at my Obsidian vault folder and told it to share that folder with all my devices. That's it. That's the setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Watching It Actually Work
&lt;/h3&gt;

&lt;p&gt;Change a file on any device. Syncthing detects it within seconds. The change propagates to the other devices. Obsidian notices the file changed and updates its view. &lt;/p&gt;

&lt;p&gt;It's not magic—it's just file watching and network sockets. But it &lt;em&gt;feels&lt;/em&gt; magic when you're used to cloud sync services that randomly decide they need five minutes to "think about it."&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Syncthing Doesn't Suck
&lt;/h2&gt;

&lt;p&gt;Block-level syncing means it only transfers what changed. Edit one paragraph? It sends that delta, not the entire file. This matters when you're on mobile data or have a 50MB vault full of images.&lt;/p&gt;

&lt;p&gt;Conflict handling is reasonable. If you somehow edit the same file on two disconnected devices (how?), it creates a conflict copy instead of randomly picking a winner. You manually merge. Annoying, but better than silent data loss.&lt;/p&gt;

&lt;p&gt;Everything's encrypted in transit. Your existential crisis notes aren't flying across the internet in plaintext for your ISP to judge.&lt;/p&gt;

&lt;h2&gt;
  
  
  The VPS Piece
&lt;/h2&gt;

&lt;p&gt;Two devices can sync directly without a VPS. Phone talks to laptop when both are online. But the VPS makes this bulletproof.&lt;/p&gt;

&lt;p&gt;I'm paranoid about losing data. Having an always-online third node means changes &lt;em&gt;always&lt;/em&gt; have somewhere to go. Plus, it's offsite. My apartment could burn down and my notes would survive.&lt;/p&gt;

&lt;p&gt;Running in Docker is just good practice. Isolated, reproducible, updateable. One &lt;code&gt;docker-compose up -d&lt;/code&gt; and it's running forever.&lt;/p&gt;

&lt;h2&gt;
  
  
  What This Actually Feels Like
&lt;/h2&gt;

&lt;p&gt;I've been running this for months. I don't think about it. That's the highest compliment I can give any infrastructure.&lt;/p&gt;

&lt;p&gt;I dump thoughts into Obsidian on my phone while walking. Those thoughts are on my laptop by the time I get home. I refactor my notes at my desk, and they're on my phone instantly. The VPS quietly keeps everything synchronized without me ever SSHing in to check on it.&lt;/p&gt;

&lt;p&gt;Zero conflicts. Zero "oops, I edited the old version" moments. Zero subscription fees.&lt;/p&gt;

&lt;h2&gt;
  
  
  If You're Technical Enough to Care
&lt;/h2&gt;

&lt;p&gt;You're probably already sold or already running something similar. If you're on the fence: one Saturday afternoon to set this up, then you never think about it again.&lt;/p&gt;

&lt;p&gt;No subscription. No trusting a third-party with your data. No wondering if the sync service will still exist in five years or if they'll get acquired and enshittified.&lt;/p&gt;

&lt;p&gt;Just files, syncing between your devices, like we've been doing since rsync was invented.&lt;/p&gt;

&lt;p&gt;If you're still paying for Obsidian Sync after reading this... I mean, that's your choice. But at least know you have options.&lt;/p&gt;

&lt;p&gt;Lets Connect:&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/adhikareeprayush" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.github.com/adhikareeprayush" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;br&gt;
&lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;Portfolio&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>obsidian</category>
      <category>automation</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Top 10 Visual Studio Code Extensions for Enhanced Productivity</title>
      <dc:creator>Prayush Adhikari</dc:creator>
      <pubDate>Sat, 28 Sep 2024 13:25:00 +0000</pubDate>
      <link>https://dev.to/adhikareeprayush/top-10-visual-studio-code-extensions-for-enhanced-productivity-4emb</link>
      <guid>https://dev.to/adhikareeprayush/top-10-visual-studio-code-extensions-for-enhanced-productivity-4emb</guid>
      <description>&lt;h2&gt;
  
  
  Top 10 VS Code Extensions You Absolutely Need (or Else!)
&lt;/h2&gt;

&lt;p&gt;So, you’ve hopped on the Visual Studio Code train, huh? Welcome aboard! It’s sleek, it’s lightweight, and, oh boy, those extensions! They’re like sprinkles on a cupcake—totally necessary. Whether you’re a coding wizard or still figuring out the difference between a variable and a function, here’s a curated list of the top 10 VS Code extensions that you should definitely check out (because why not?).&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;strong&gt;Prettier - Code Formatter&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Ever looked at your code and thought, “Yikes, what a mess”? Prettier is here to save the day! This opinionated code formatter works its magic on multiple languages, enforcing a consistent style. It's like having a professional organizer for your codebase. Trust me, your team will thank you (and maybe even throw you a party).&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode" rel="noopener noreferrer"&gt;Get Started with Prettier!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;strong&gt;ESLint&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For all you JavaScript and TypeScript aficionados, ESLint is like that annoying friend who always points out your mistakes—except this one helps you write cleaner code. It spots and fixes issues in real-time, so you can avoid those embarrassing “uh-oh” moments during code reviews.&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint" rel="noopener noreferrer"&gt;Learn More About ESLint&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;strong&gt;Live Server&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Web developers, rejoice! The Live Server extension is your best friend. It sets up a local server and gives you live reload capabilities. So while you're frantically changing your HTML, CSS, and JavaScript, you’ll see those changes in real-time. No more refresh, refresh, refresh. Just sit back and watch the magic unfold!&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer" rel="noopener noreferrer"&gt;Check Out Live Server&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. &lt;strong&gt;GitHub Copilot&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine having an AI-powered coding buddy who gets your coding style. GitHub Copilot offers suggestions for entire lines of code or functions, helping you tackle repetitive tasks and even suggesting cool solutions you might not have thought of. It’s like magic for your code!&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=GitHub.copilot" rel="noopener noreferrer"&gt;Explore GitHub Copilot&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. &lt;strong&gt;Docker&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For those of you diving into the world of containers (not the ones you keep your leftovers in), the Docker extension is a game changer. Manage and deploy Docker containers right from VS Code like a boss. It’s like having a personal assistant for your containerized applications, minus the coffee runs.&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker" rel="noopener noreferrer"&gt;Get Docker Here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. &lt;strong&gt;Vim&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you’re a fan of Vim’s powerful keybindings, you’re in luck. The Vim extension brings all those shortcuts to VS Code, so you can navigate and edit like a pro without ever lifting your fingers from the keyboard. It’s like giving your IDE superpowers, and you’ll feel unstoppable!&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=vscodevim.vim" rel="noopener noreferrer"&gt;Try Vim for VS Code&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. &lt;strong&gt;Auto Rename Tag&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For all the HTML/XML folks out there, Auto Rename Tag is a lifesaver. It automatically updates paired tags when you edit one of them, helping you avoid mismatches and keeping your code neat. It’s like having a cleanup crew for your tags.&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag" rel="noopener noreferrer"&gt;Check Out Auto Rename Tag&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. &lt;strong&gt;Error Lens&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s face it: errors are a fact of coding life. But Error Lens makes spotting them way easier by showing error and warning messages directly in your code, right where the problem is. No more scrolling around looking for the issues—just fix it and move on!&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens" rel="noopener noreferrer"&gt;Get Error Lens&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. &lt;strong&gt;CodeSnap&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Love sharing your code online? CodeSnap makes it simple to take beautiful screenshots of your code, perfect for blog posts, social media, or documentation. Say goodbye to clunky screenshots and hello to polished, professional snaps.&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=adpyke.codesnap" rel="noopener noreferrer"&gt;Get CodeSnap&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. &lt;strong&gt;Thunder Client&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Testing APIs has never been easier! Thunder Client is a super-lightweight REST API client right inside VS Code, making it a fantastic alternative to bulky tools like Postman. Test APIs without ever leaving your editor.&lt;br&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client" rel="noopener noreferrer"&gt;Discover Thunder Client&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;If you're looking to elevate your development experience with these extensions and more, feel free to check out my link to &lt;a href="https://code.visualstudio.com/?WT.mc_id=academic&amp;amp;wt.mc_id=studentamb_293386" rel="noopener noreferrer"&gt;Visual Studio Code&lt;/a&gt;. It’s a fantastic resource that can help you get set up and make your coding life smoother than ever. So, gear up, download VS Code, and let’s make some code magic happen!&lt;/p&gt;




&lt;h2&gt;
  
  
  Join the PrayushDev Community!
&lt;/h2&gt;

&lt;p&gt;Before you go, I'm excited to announce the launch of my weekly newsletter: PrayushDev! 🎉&lt;/p&gt;

&lt;p&gt;Why should you subscribe? Here's what you'll get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bite-sized introductions to hot tech topics&lt;/li&gt;
&lt;li&gt;Insider tips and tricks from the world of development&lt;/li&gt;
&lt;li&gt;Early access to upcoming "React Unmasked" episodes&lt;/li&gt;
&lt;li&gt;A chance to be part of a growing community of passionate devs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't miss out on this opportunity to stay at the cutting edge of tech. Subscribe now and let's grow together!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://prayushadhikari.com.np" rel="noopener noreferrer"&gt;prayushadhikari.com.np&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>productivity</category>
      <category>coding</category>
      <category>vscode</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
