<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Santosh Gupta on Medium]]></title>
        <description><![CDATA[Stories by Santosh Gupta on Medium]]></description>
        <link>https://medium.com/@guptasantosh327?source=rss-2a5f8ebda53d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*V8xo18QbnCju8suh</url>
            <title>Stories by Santosh Gupta on Medium</title>
            <link>https://medium.com/@guptasantosh327?source=rss-2a5f8ebda53d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:23:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@guptasantosh327/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[7 Things I Wish migrate-mongo Had After a Few Production Incidents]]></title>
            <link>https://medium.com/@guptasantosh327/7-things-i-wish-migrate-mongo-had-after-a-few-production-incidents-88d60ab6a8f4?source=rss-2a5f8ebda53d------2</link>
            <guid isPermaLink="false">https://medium.com/p/88d60ab6a8f4</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[database-migration]]></category>
            <dc:creator><![CDATA[Santosh Gupta]]></dc:creator>
            <pubDate>Mon, 10 Aug 2026 06:11:34 GMT</pubDate>
            <atom:updated>2026-08-10T06:21:23.334Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*c1ny9R0QTJwUe5viXBySJQ.jpeg" /></figure><p>I’ve used migrate-mongo for years.</p><p>It’s simple, reliable, and honestly a good choice for many projects.</p><p>But as our application grew, I started running into the same problems repeatedly: rollbacks, concurrent deployments, migration drift, and debugging what actually happened months ago.</p><p>Eventually, I stopped working around those problems and built mongo-migrate-kit.</p><p>Here are the seven things I wanted.</p><h3>1. Roll back a specific migration</h3><p>This was the one that frustrated me the most.</p><p>Imagine three migrations went out:</p><pre>migration A  ✓<br>migration B  ✗<br>migration C  ✓</pre><p>I only want to undo B.</p><p>With migrate-mongo, rollback is based on the latest migration. There&#39;s no simple way to say &quot;undo this particular migration.&quot;</p><p>So you either roll back more than you want or start doing things manually.</p><p>I’ve done the latter in production. Not fun.</p><p>With mongo-migrate-kit:</p><pre>mmk down 20260101-the-broken-one.js</pre><p>Or if you actually want to roll back a batch:</p><pre>mmk down --batch 3</pre><h3>2. Dry run before touching production</h3><p>Before running migrations in production, I want to know:</p><ul><li>Which migrations are pending?</li><li>What order will they run in?</li><li>What is about to happen?</li></ul><p>That’s why mmk has dry-run support:</p><pre>mmk dry-run up<br>mmk dry-run down</pre><p>It shows the plan without changing the database.</p><p>I run this before production migrations now. It’s a small thing, but it removes a lot of uncertainty.</p><h3>3. Two deployments shouldn’t run migrations simultaneously</h3><p>We once had two deployments trigger migrations almost at the same time.</p><p>Both processes thought they were in charge.</p><p>That’s not a situation you want with database migrations.</p><p>mongo-migrate-kit uses a database-backed atomic lock:</p><pre>Deploy A → acquire lock → run migrations → release</pre><pre>Deploy B → lock exists → stop</pre><p>The lock has a TTL, so a crashed process doesn’t leave the database permanently locked.</p><p>And if you don’t need locking locally:</p><pre>mmk up --no-lock</pre><h3>4. Know when an old migration was modified</h3><p>This one is easy to overlook.</p><p>A migration runs in production.</p><p>Someone later edits the file.</p><p>The filename is still the same, so the migration history says everything is fine.</p><p>But the code that exists in Git is no longer the code that ran in production.</p><p>mongo-migrate-kit stores a SHA-256 checksum for every migration.</p><p>If the file changes, you can see the drift.</p><p>And with:</p><pre>mmk up --strict</pre><p>the migration can fail instead of silently continuing.</p><p>If the change was intentional:</p><pre>mmk up 20260101-add-index.js --force</pre><p>Migration files are history. I think they should be treated that way.</p><h3>5. Redo shouldn’t require two commands</h3><p>During development, my migration loop was basically:</p><pre>migrate down<br>migrate up</pre><p>Over and over.</p><p>So I added:</p><pre>mmk redo</pre><p>Or:</p><pre>mmk redo 20260101-add-index.js</pre><p>Small feature.</p><p>Probably the command I use most while writing migrations.</p><h3>6. Rollbacks shouldn’t erase history</h3><p>A rollback is still an event.</p><p>If a migration ran on Monday and was reverted on Tuesday, I want that information to remain in the database.</p><p>Instead of deleting the migration record, mmk marks it as:</p><pre>applied → reverted</pre><p>The history keeps information such as:</p><pre>batch<br>status<br>appliedAt<br>revertedAt<br>duration<br>checksum<br>environment<br>executedBy</pre><p>Months later, you can still answer:</p><blockquote><em>“Did this migration actually run in production?”</em></blockquote><p>That’s important when debugging old incidents.</p><h3>7. TypeScript shouldn’t need a separate setup</h3><p>If your application is TypeScript, migration files should be TypeScript too.</p><p>With mongo-migrate-kit:</p><pre>import type { MigrationContext } from &#39;mongo-migrate-kit&#39;;</pre><pre>export async function up({ db }: MigrationContext): Promise&lt;void&gt; {<br>  await db.collection(&#39;users&#39;).createIndex(<br>    { email: 1 },<br>    { unique: true }<br>  );<br>}</pre><pre>export async function down({ db }: MigrationContext): Promise&lt;void&gt; {<br>  await db.collection(&#39;users&#39;).dropIndex(&#39;email_1&#39;);<br>}</pre><p>No extra ts-node setup or build step.</p><p>JavaScript works too, including ESM and CommonJS.</p><h3>Should you switch from migrate-mongo?</h3><p>Maybe not.</p><p>If you have a small project and a handful of migrations, migrate-mongo is probably perfectly fine.</p><p>I used it for years.</p><p>These problems only started becoming painful when we had more migrations, more developers, more environments, and CI/CD deployments running against production.</p><p>That’s when migration tooling stops being just:</p><blockquote><em>“Run these files in order.”</em></blockquote><p>It becomes infrastructure.</p><p>And infrastructure needs things like locking, audit history, drift detection, and safe rollbacks.</p><h3>Already using migrate-mongo?</h3><p>You don’t need to rewrite your existing migrations.</p><p>mongo-migrate-kit can import your existing history:</p><pre>npm install mongo-migrate-kit mongodb <br>npx mmk import --dry-run <br>npx mmk import mmk up</pre><p>The old changelog isn’t modified.</p><p>That’s the reason I built this tool.</p><p>Not because migrate-mongo is bad.</p><p>Because after enough production incidents, I knew exactly which features I wanted in my migration workflow.</p><p><a href="https://github.com/your-repo/mongo-migrate-kit"><strong>mongo-migrate-kit</strong></a> is open source.</p><p>If you’ve had a migration go wrong in production, I’d genuinely like to hear what happened. Those stories are usually where the best tooling ideas come from.</p><p><em>Originally published at </em><a href="https://dev.to/santosh327/7-things-i-wish-migrate-mongo-had-after-a-few-production-incidents-4g2b"><em>https://dev.to</em></a><em> on August 10, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88d60ab6a8f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving from migrate-mongo to mongo-migrate-kit Without Re-Running Old Migrations]]></title>
            <link>https://medium.com/@guptasantosh327/moving-from-migrate-mongo-to-mongo-migrate-kit-without-re-running-old-migrations-df9d20747526?source=rss-2a5f8ebda53d------2</link>
            <guid isPermaLink="false">https://medium.com/p/df9d20747526</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[data-migration-tool]]></category>
            <dc:creator><![CDATA[Santosh Gupta]]></dc:creator>
            <pubDate>Thu, 25 Jun 2026 11:50:18 GMT</pubDate>
            <atom:updated>2026-06-25T11:50:18.170Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*c1ny9R0QTJwUe5viXBySJQ.jpeg" /></figure><blockquote><em>Part 2 of the MongoDB Migration Problems Series</em></blockquote><p>Before reading this article, you may want to check out Part 1 where I explain the deployment issue that eventually led me to build mongo-migrate-kit.</p><p><strong>Part 1:</strong> I Built a MongoDB Migration Tool After One Bad Deploy<br><a href="https://dev.to/santosh327/i-built-a-mongodb-migration-tool-after-one-bad-deploy-18j6">https://dev.to/santosh327/i-built-a-mongodb-migration-tool-after-one-bad-deploy-18j6</a></p><p>If you’re using <strong>migrate-mongo</strong> and considering a switch, the biggest concern usually isn’t features.</p><p>It’s this:</p><p><strong>“Will I have to re-run old migrations or risk production data?”</strong></p><p>The short answer is no.</p><p>I built <strong>mongo-migrate-kit</strong> with migration adoption as a first-class feature because switching migration tools shouldn’t feel risky.</p><h3>The Problem</h3><p>Most teams already have months or years of migration history.</p><p>Re-running old migrations is dangerous.</p><p>Editing migration records manually is even worse.</p><p>What you really want is a way to tell the new tool:</p><blockquote><em>“These migrations already ran. Start tracking them and leave everything else alone.”</em></blockquote><p>That’s exactly what mongo-migrate-kit does.</p><h3>Import Existing migrate-mongo History</h3><p>First, install the package:</p><pre>npm install mongo-migrate-kit mongodb</pre><p>Preview the import:</p><pre>npx mmk import --dry-run</pre><p>This reads your existing migrate-mongo changelog and shows what will be imported.</p><p>Nothing is written to the database.</p><p>Once you’re happy with the output:</p><pre>npx mmk import</pre><p>The migration history is copied into mongo-migrate-kit&#39;s tracking collection.</p><p>Your original migrate-mongo changelog remains untouched.</p><h3>What Happens Next?</h3><p>After importing:</p><pre>npx mmk status</pre><p>Previously applied migrations appear as applied.</p><p>Any migration files that haven’t run yet remain pending.</p><p>When you run:</p><pre>npx mmk up</pre><p>Only pending migrations execute.</p><p>Old migrations are never re-run.</p><h3>Why This Matters</h3><p>The hardest part of switching migration tools isn’t installing a new package.</p><p>It’s trusting that the new tool understands your existing migration history.</p><p>That’s why I focused heavily on safe migration adoption while building mongo-migrate-kit.</p><p>You shouldn’t have to:</p><ul><li>Re-run old migrations</li><li>Modify production data</li><li>Edit migration records manually</li><li>Risk downtime during migration</li></ul><p>The goal is simple: import the history and keep moving forward.</p><h3>What You Get After Switching</h3><p>Beyond migration adoption, mongo-migrate-kit adds several features that I found myself missing in production workflows:</p><ul><li>Rollback specific migrations or batches</li><li>Dry-run support before executing migrations</li><li>SHA-256 checksum validation for migration files</li><li>Distributed migration locking</li><li>Redo support</li><li>Full TypeScript support</li></ul><p>These features came directly from real deployment pain points rather than a desire to build “yet another migration tool.”</p><h3>Documentation &amp; Links</h3><p>📘 Documentation<br><a href="https://mongo-migrate-kit.vercel.app/">https://mongo-migrate-kit.vercel.app/</a></p><p>📦 npm<br><a href="https://www.npmjs.com/package/mongo-migrate-kit">https://www.npmjs.com/package/mongo-migrate-kit</a></p><p>💻 GitHub<br><a href="https://github.com/guptasantosh327/mongo-migrate-kit">https://github.com/guptasantosh327/mongo-migrate-kit</a></p><h3>Final Thoughts</h3><p>Switching migration tools should not feel like a gamble.</p><p>If you’re looking for a <strong>migrate-mongo alternative</strong> and want a <strong>MongoDB migration tool for Node.js</strong> that can safely adopt your existing migration history, give <strong>mongo-migrate-kit</strong> a try.</p><p>And if you’re already using mongo-migrate-kit, start with:</p><pre>npx mmk import --dry-run</pre><p>It’s the safest way to see exactly what will happen before committing to anything.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df9d20747526" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a MongoDB Migration Tool After One Bad Deploy]]></title>
            <link>https://medium.com/@guptasantosh327/i-built-a-mongodb-migration-tool-after-one-bad-deploy-adf38a5578bc?source=rss-2a5f8ebda53d------2</link>
            <guid isPermaLink="false">https://medium.com/p/adf38a5578bc</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Santosh Gupta]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 07:16:07 GMT</pubDate>
            <atom:updated>2026-06-25T11:35:18.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZNesTPNQHfMkcIWzbN13lQ.png" /></figure><p>A few months ago I shipped a bad MongoDB migration.</p><p>Classic mistake.</p><p>I had run 3 migrations.</p><p>The third one had a bug.</p><p>I only wanted to rollback <strong>that migration</strong>.</p><p>Turns out with migrate-mongo, rollback is mostly:</p><blockquote><em>undo the last applied migration</em></blockquote><p>Which sounds fine until you have:</p><ul><li>multiple deployments</li><li>multiple environments</li><li>teammates deploying too</li></ul><p>“Last applied” stops feeling obvious.</p><p>I ended up manually undoing DB changes and fixing migration history myself.</p><p>Not fun.</p><p>That was the moment I realized our migration setup had started breaking down as the project grew.</p><h3>The stuff I kept wishing existed</h3><p>After that incident I wrote down all the things I wanted from a migration tool:</p><ul><li>run <strong>one migration file</strong></li><li>rollback <strong>a specific migration</strong></li><li>preview migrations before running (dry-run)</li><li>avoid concurrent deploys stepping on each other (locking)</li><li>detect edited migrations (checksums)</li><li>a redo command for local development</li><li>TypeScript support without setup pain</li><li>migration history that doesn’t disappear after rollback</li></ul><p>None of these felt unusual.</p><p>They felt like things you eventually want once your project stops being small.</p><p>So I ended up building one.</p><h3>Meet mongo-migrate-kit</h3><p>CLI name: mmk</p><p>A few examples:</p><p>Run pending migrations:</p><p>Rollback a specific migration:</p><p>mmk down migration-name</p><p>Preview before touching production:</p><p>Redo during development:</p><h3>The hard problem: switching tools safely</h3><p>This was the part I cared about most.</p><p>Migration tools are easy to adopt on day 1.</p><p>They’re painful to switch after 50+ migrations already exist.</p><p>I didn’t want people to:</p><ul><li>rerun old migrations</li><li>recreate indexes</li><li>duplicate seed data</li><li>accidentally touch production data</li></ul><p>It reads your existing migrate-mongo changelog and adopts the migration history.</p><p>only runs new migrations.</p><p>No replaying old history.</p><p>No scary production moments.</p><h3>One thing I intentionally don’t support</h3><p>Imported migrate-mongo migrations are forward-only.</p><p>You can’t rollback imported migrations using mmk.</p><p>I could have tried to force compatibility, but I didn’t trust it enough to be safe.</p><p>Different execution models + database tooling = not something I wanted to gamble with.</p><p>So the tool fails loudly instead of pretending everything is reversible.</p><h3>Curious what other teams are doing</h3><p>If you’re running MongoDB migrations in production:</p><ul><li>What’s your current setup?</li><li>Have you hit similar pain points?</li><li>Are you still happy with migrate-mongo?</li></ul><p>Would genuinely love feedback.</p><p>Project:<a href="https://www.npmjs.com/package/mongo-migrate-kit">mongo-migrate-kit</a></p><p>Docs/demo: <a href="https://mongo-migrate-kit.vercel.app/">mongo-migrate-kit.vercel.app</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adf38a5578bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Practical Approach of Replica Set — MongoDB — Part 2]]></title>
            <link>https://medium.com/@guptasantosh327/practical-approach-of-replica-set-mongodb-part-2-2ec3c1aaed0d?source=rss-2a5f8ebda53d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ec3c1aaed0d</guid>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[replicaset]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Santosh Gupta]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 17:03:23 GMT</pubDate>
            <atom:updated>2025-12-27T17:06:06.563Z</atom:updated>
            <content:encoded><![CDATA[<h3>Practical Approach To Replica Set — MongoDB — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHnvvovIHT7rEQZED5xdIw.jpeg" /></figure><p><strong>Haven’t read my PART 1 yet?</strong><br> I highly recommend checking it out first so you have the theory ready for Part 2:</p><p>👉 <a href="https://medium.com/@guptasantosh327/practical-approach-of-replica-set-mongodb-c59885ade045">https://medium.com/@guptasantosh327/practical-approach-of-replica-set-mongodb-c59885ade045</a></p><h3>What we are building</h3><p>A <strong>replica set</strong> = <strong>1 Primary + 2 Secondaries</strong></p><p>Purpose:</p><ul><li>High availability</li><li>Automatic failover</li><li>Data safety</li></ul><h4>Architecture we’ll use</h4><p>Node 1 -&gt; localhost:27017 Primary (initially)</p><p>Node 2 -&gt; localhost:27018 Secondary</p><p>Node 3 -&gt; localhost:27019 Secondary</p><p><strong>Same machine is OK</strong> (for learning)</p><p><strong>STEP 1: Create data directories (WHY?)</strong></p><p>Each mongod:</p><ul><li>Stores data on disk</li><li>Must have <strong>its own dbpath</strong></li><li>Must not share files</li></ul><pre>mkdir -p ~/mongo-rs/node1 ~/mongo-rs/node2 ~/mongo-rs/node3<br></pre><p>Output: It created three folders node1, node2 and node3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Uej9NCACifAfy4RKKStgpQ.png" /></figure><p>👉 <strong>Why</strong>:<br> Replica set nodes must have <strong>isolated storage</strong> so they don’t corrupt each other’s data.</p><h3>STEP 2: Start MongoDB nodes with replica set enabled</h3><h3>Start Node 1</h3><pre>mongod \<br>  --port 27017 \<br>  --dbpath ~/mongo-rs/node1 \<br>  --replSet rs0 \<br>  --bind_ip localhost</pre><h3>Start Node 2</h3><pre>mongod \<br>  --port 27018 \<br>  --dbpath ~/mongo-rs/node2 \<br>  --replSet rs0 \<br>  --bind_ip localhost</pre><h3>Start Node 3</h3><pre>mongod \<br>  --port 27019 \<br>  --dbpath ~/mongo-rs/node3 \<br>  --replSet rs0 \<br>  --bind_ip localhost</pre><p>As soon as you entered the command lots of logs will start appending your terminal. Nothing to vary about mostly its all the pre load up configuration talk.</p><p>Flag:</p><p>--replSet rs0Replica set name — All nodes must have same name</p><p>--dbpathData directory — Each node needs its own data</p><p>--portNetwork port — Allows multiple nodes on same machine</p><p>--bind_ipAllowed IPs — Security &amp; access control</p><p>⚠️ If <strong>replica set name differs</strong>, nodes will <strong>never join</strong>.</p><h3>STEP 3: Connect to first node (seed node)</h3><pre>mongosh --port 27017</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zu2l4UdA0QL1C4wmYhE8oQ.png" /></figure><p>At this point:</p><ul><li>MongoDB is running</li><li>Replica set is <strong>not initialized</strong></li><li>No primary exists yet</li></ul><blockquote><strong>Note: You might be getting some errors in all three terminal don’t worry once you connect all the node it will not throw error</strong></blockquote><h3>STEP 4: Initialize the replica set (MOST IMPORTANT STEP)</h3><p>Run this command in the terminal where you have connect to node 1 on step 3.</p><pre>rs.initiate({<br>  _id: &quot;rs0&quot;,<br>  members: [<br>    { _id: 0, host: &quot;localhost:27017&quot; },<br>    { _id: 1, host: &quot;localhost:27018&quot; },<br>    { _id: 2, host: &quot;localhost:27019&quot; }<br>  ]<br>})</pre><h3>What happens internally (VERY IMPORTANT)</h3><p>When you run rs.initiate():</p><ol><li>MongoDB writes <strong>replica set metadata</strong></li><li>Nodes start <strong>heartbeat checks</strong></li><li>An <strong>election</strong> happens</li><li>One node becomes <strong>PRIMARY</strong></li><li>Others become <strong>SECONDARY</strong></li></ol><p>You’ll see:</p><pre>{ ok: 1 }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-sZTknbtD7iE-QmWZ7w5g.png" /></figure><p>STEP 5: Verify replica set status</p><pre>rs.status()</pre><blockquote>Look for: “stateStr” : “PRIMARY” “stateStr” : “SECONDARY” it will tell you extactly which one is primary and which one is secondary</blockquote><pre>{<br>  set: &#39;rs0&#39;,<br>  date: ISODate(&#39;2025-12-27T16:31:58.444Z&#39;),<br>  myState: 1,<br>  term: Long(&#39;1&#39;),<br>  syncSourceHost: &#39;&#39;,<br>  syncSourceId: -1,<br>  heartbeatIntervalMillis: Long(&#39;2000&#39;),<br>  majorityVoteCount: 2,<br>  writeMajorityCount: 2,<br>  votingMembersCount: 3,<br>  writableVotingMembersCount: 3,<br>  optimes: {<br>    lastCommittedOpTime: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>    lastCommittedWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>    readConcernMajorityOpTime: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>    appliedOpTime: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>    durableOpTime: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>    lastAppliedWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>    lastDurableWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;)<br>  },<br>  lastStableRecoveryTimestamp: Timestamp({ t: 1766853083, i: 1 }),<br>  electionCandidateMetrics: {<br>    lastElectionReason: &#39;electionTimeout&#39;,<br>    lastElectionDate: ISODate(&#39;2025-12-27T16:29:43.184Z&#39;),<br>    electionTerm: Long(&#39;1&#39;),<br>    lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 1766852972, i: 1 }), t: Long(&#39;-1&#39;) },<br>    lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1766852972, i: 1 }), t: Long(&#39;-1&#39;) },<br>    numVotesNeeded: 2,<br>    priorityAtElection: 1,<br>    electionTimeoutMillis: Long(&#39;10000&#39;),<br>    numCatchUpOps: Long(&#39;0&#39;),<br>    newTermStartDate: ISODate(&#39;2025-12-27T16:29:43.257Z&#39;),<br>    wMajorityWriteAvailabilityDate: ISODate(&#39;2025-12-27T16:29:43.809Z&#39;)<br>  },<br>  members: [<br>    {<br>      _id: 0,<br>      name: &#39;localhost:27017&#39;,<br>      health: 1,<br>      state: 1,<br>      stateStr: &#39;PRIMARY&#39;,<br>      uptime: 207,<br>      optime: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>      optimeDate: ISODate(&#39;2025-12-27T16:31:53.000Z&#39;),<br>      lastAppliedWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>      lastDurableWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>      syncSourceHost: &#39;&#39;,<br>      syncSourceId: -1,<br>      infoMessage: &#39;&#39;,<br>      electionTime: Timestamp({ t: 1766852983, i: 1 }),<br>      electionDate: ISODate(&#39;2025-12-27T16:29:43.000Z&#39;),<br>      configVersion: 1,<br>      configTerm: 1,<br>      self: true,<br>      lastHeartbeatMessage: &#39;&#39;<br>    },<br>    {<br>      _id: 1,<br>      name: &#39;localhost:27018&#39;,<br>      health: 1,<br>      state: 2,<br>      stateStr: &#39;SECONDARY&#39;,<br>      uptime: 146,<br>      optime: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>      optimeDurable: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>      optimeDate: ISODate(&#39;2025-12-27T16:31:53.000Z&#39;),<br>      optimeDurableDate: ISODate(&#39;2025-12-27T16:31:53.000Z&#39;),<br>      lastAppliedWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>      lastDurableWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>      lastHeartbeat: ISODate(&#39;2025-12-27T16:31:57.337Z&#39;),<br>      lastHeartbeatRecv: ISODate(&#39;2025-12-27T16:31:58.344Z&#39;),<br>      pingMs: Long(&#39;0&#39;),<br>      lastHeartbeatMessage: &#39;&#39;,<br>      syncSourceHost: &#39;localhost:27017&#39;,<br>      syncSourceId: 0,<br>      infoMessage: &#39;&#39;,<br>      configVersion: 1,<br>      configTerm: 1<br>    },<br>    {<br>      _id: 2,<br>      name: &#39;localhost:27019&#39;,<br>      health: 1,<br>      state: 2,<br>      stateStr: &#39;SECONDARY&#39;,<br>      uptime: 146,<br>      optime: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>      optimeDurable: { ts: Timestamp({ t: 1766853113, i: 1 }), t: Long(&#39;1&#39;) },<br>      optimeDate: ISODate(&#39;2025-12-27T16:31:53.000Z&#39;),<br>      optimeDurableDate: ISODate(&#39;2025-12-27T16:31:53.000Z&#39;),<br>      lastAppliedWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>      lastDurableWallTime: ISODate(&#39;2025-12-27T16:31:53.330Z&#39;),<br>      lastHeartbeat: ISODate(&#39;2025-12-27T16:31:57.337Z&#39;),<br>      lastHeartbeatRecv: ISODate(&#39;2025-12-27T16:31:58.343Z&#39;),<br>      pingMs: Long(&#39;0&#39;),<br>      lastHeartbeatMessage: &#39;&#39;,<br>      syncSourceHost: &#39;localhost:27017&#39;,<br>      syncSourceId: 0,<br>      infoMessage: &#39;&#39;,<br>      configVersion: 1,<br>      configTerm: 1<br>    }<br>  ],<br>  ok: 1,<br>  &#39;$clusterTime&#39;: {<br>    clusterTime: Timestamp({ t: 1766853113, i: 1 }),<br>    signature: {<br>      hash: Binary.createFromBase64(&#39;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&#39;, 0),<br>      keyId: Long(&#39;0&#39;)<br>    }<br>  },<br>  operationTime: Timestamp({ t: 1766853113, i: 1 })<br>}</pre><p>Quick Check to see in which node you are and some other metadata</p><pre>db.isMaster() // Older verison<br>db.hello() // new verison</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FD2QSfaJUKEa3kksM32f1g.png" /></figure><h3>STEP 6: Test replication (PROOF it works)</h3><h4>Insert data (on PRIMARY only)</h4><pre>use test // Your database name<br>db.users.insertOne({ name: &quot;Santosh&quot;, role: &quot;Developer&quot; })</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bE0B9qYPjSxCyuEFSaP7ig.png" /></figure><h4>Read from secondary</h4><p>Connect to secondary nodes:</p><pre>mongosh --port 27018</pre><pre>mongosh --port 27019</pre><p>Try reading:</p><pre>db.users.find()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezlDOUSvTTG8FVx9BW7NPA.png" /></figure><p>By default primary send the data to secondary nodes thats why when we ran the command in primary and connected to secondary DB it already had the document.</p><blockquote>Note: Your Server is already running from step 2 all three nodes</blockquote><p>Optionally if on older version use this below command in Primary Connection to allow secondary read.</p><pre>rs.secondaryOk()</pre><h3>STEP 7: Understand elections (FAILOVER DEMO)</h3><h4>Stop the primary</h4><p>Press Ctrl + C on primary terminal from step 2.</p><p>Try to connect to primary DB from terminal it will throw error which means primary is truly down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9GfBnP775xkvbW9aveIVQ.png" /></figure><h4>What happens?</h4><ul><li>Secondaries detect failure</li><li>Election begins</li><li>New primary is chosen</li></ul><p>Lets check status on the secondary nodes by using below command:</p><pre>rs.status()</pre><p>Particulary look for <strong><em>stateStr</em> </strong>key in members array of the output.</p><p>Primary Status: (not reachable/healthy)</p><p>Secondary Node 1: PRIMARY</p><p>Secondary Node 2: SECONDARY</p><p>Wanna learn more about the election Matrix loook for <strong><em>electionCandidateMetrics</em></strong></p><p>✔️ <strong>Zero manual work</strong></p><h3>STEP 8: Why odd number of nodes matters</h3><p>MongoDB uses <strong>majority voting</strong></p><blockquote>Even number can be dangerous (split brain) alway use Odd number of nodes</blockquote><p>That’s why:</p><ul><li>3, 5, 7 nodes recommended</li><li>Or <strong>2 data nodes + 1 arbiter</strong></li></ul><h3>STEP 9: Arbiter (Optional)</h3><p>Add arbiter:</p><pre>rs.addArb(&quot;localhost:27020&quot;)</pre><p>Arbiter:</p><ul><li>Votes only</li><li>No data</li><li>Helps reach majority</li></ul><p>Part 3: I can deep dive in Node.js implementation of MongoDB Replica</p><p>That’s all for now. <br>Thanks for reading, and if this made replica sets clearer for you, don’t forget to give it a clap 👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ec3c1aaed0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Practical Approach of Replica Set — MongoDB]]></title>
            <link>https://medium.com/@guptasantosh327/practical-approach-of-replica-set-mongodb-c59885ade045?source=rss-2a5f8ebda53d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c59885ade045</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[replicaset]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[practical-guides]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Santosh Gupta]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 15:57:31 GMT</pubDate>
            <atom:updated>2025-12-27T17:05:37.099Z</atom:updated>
            <content:encoded><![CDATA[<h3>Practical Approach To Replica Set — MongoDB — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHnvvovIHT7rEQZED5xdIw.jpeg" /></figure><p>When I started learning <strong>MongoDB replica sets</strong>, everything sounded mysterious:</p><ul><li>Oplog</li><li>Elections</li><li>Rollbacks</li><li>Read preferences</li><li>Write concerns</li></ul><p>Most explanations were either <strong>too shallow</strong> or <strong>too complex</strong> — and often missed practical context.</p><p>This post is written for:</p><ul><li>developers learning MongoDB</li><li>engineers revising fundamentals</li><li>future-me coming back for a refresher</li></ul><p>👉 <strong>This is Part 1 (theory).</strong><br>👉 <strong>Part 2 will cover commands, screenshots, and hands-on demos.</strong></p><p>For now, let’s focus on building the <strong>right mental model</strong>.</p><h3>What Is a MongoDB Replica Set?</h3><p>A <strong>replica set</strong> is a group of MongoDB servers that store the <strong>same data</strong>.</p><ul><li>One node is the <strong>Primary</strong></li><li>Other nodes are <strong>Secondaries</strong></li><li>Only the <strong>Primary accepts writes</strong></li><li>Secondaries <strong>copy data from the Primary</strong></li></ul><h3>Why replica sets exist</h3><ul><li>High availability</li><li>Automatic failover</li><li>Data safety</li></ul><h3>The Core Idea Behind Replica Sets</h3><p>MongoDB <strong>does not copy entire database files</strong> between servers.</p><p>Instead, it replicates <strong>operations (writes)</strong> — in order.</p><p>This is powered by the <strong>oplog</strong>.</p><h3>What Is the Oplog?</h3><p>The <strong>oplog (operations log)</strong> is a special <strong>capped collection</strong>:</p><pre>local.oplog.rs</pre><p>It stores <strong>every write operation</strong> that happens on the Primary, in order.</p><h3>Example oplog entry</h3><pre>{<br>  &quot;ts&quot;: Timestamp(1700000000, 1),<br>  &quot;op&quot;: &quot;i&quot;,<br>  &quot;ns&quot;: &quot;app.users&quot;,<br>  &quot;o&quot;: { &quot;_id&quot;: 1, &quot;name&quot;: &quot;Santosh&quot; }<br>}</pre><h3>Field meanings</h3><ul><li><strong>ts</strong> → Logical timestamp (ordering)</li><li><strong>op</strong> → Operation type<br> (i = insert, u = update, d = delete, c = command)</li><li><strong>ns</strong> → database.collection</li><li><strong>o</strong> → actual operation data</li></ul><h3>How Replication Actually Works</h3><pre>Client writes to Primary<br>        ↓<br>Primary writes to oplog<br>        ↓<br>Secondaries tail the oplog<br>        ↓<br>Secondaries replay operations</pre><p>This is <strong>event-based replication</strong>, not file syncing.</p><p>You can inspect oplog details using:</p><pre>rs.printReplicationInfo()</pre><p>This shows:</p><ul><li>oplog size</li><li>how much history it retains</li></ul><blockquote><em>Rule of thumb:<br> Your oplog window must be </em><strong><em>larger than your worst-case replication lag</em></strong><em>.</em></blockquote><h3>Why is the oplog capped?</h3><ul><li>Fixed size prevents unlimited disk growth</li><li>Old entries are automatically removed</li></ul><p>If a secondary falls too far behind and misses oplog entries, a <strong>full resync</strong> is required.</p><h3>Elections: Choosing a Primary</h3><p>MongoDB nodes constantly send <strong>heartbeats</strong> to each other.</p><p>If the Primary:</p><ul><li>crashes</li><li>becomes unreachable</li><li>is stepped down</li></ul><p>👉 an <strong>election starts automatically</strong>.</p><h3>How MongoDB decides the new Primary</h3><p>MongoDB prefers a node that:</p><ol><li>Has the <strong>latest oplog</strong></li><li>Has <strong>higher priority</strong></li><li>Is healthy and reachable</li></ol><h3>Priority example configuration</h3><pre>rs.reconfig({<br>  _id: &quot;rs0&quot;,<br>  members: [<br>    { _id: 0, host: &quot;node1:27017&quot;, priority: 2 },<br>    { _id: 1, host: &quot;node2:27017&quot;, priority: 1 },<br>    { _id: 2, host: &quot;node3:27017&quot;, priority: 0 }<br>  ]<br>})</pre><ul><li>priority: 0 → node can <strong>never become Primary</strong></li><li>Ideal for analytics or backup nodes</li></ul><p>Only <strong>one Primary</strong> can exist at a time.</p><h3>Rollbacks: Undoing Writes</h3><p>A <strong>rollback</strong> happens when:</p><ul><li>a write is accepted</li><li>but <strong>not replicated to a majority</strong></li><li>and a failover happens</li></ul><h3>Example scenario</h3><pre>Primary accepts write (w:1)<br>Primary crashes before replication<br>Secondary becomes new Primary<br>Old Primary rejoins</pre><p>Now:</p><ul><li>Old Primary has extra data</li><li>New Primary does not</li></ul><p>MongoDB <strong>rolls back</strong> the extra writes.</p><p>Rolled-back data:</p><ul><li>is removed from the database</li><li>is saved to a rollback folder on disk</li><li>can be inspected manually</li></ul><h3>The Golden Rule</h3><blockquote><strong><em>Writes acknowledged with </em></strong><strong><em>w:majority are never rolled back</em></strong></blockquote><p>This single rule explains <strong>why write concerns matter</strong>.</p><h3>Read Preferences</h3><p>By default:</p><pre>Reads → Primary</pre><p>MongoDB allows reading from secondaries to reduce load.</p><p>Common options:</p><ul><li>secondary</li><li>secondaryPreferred</li><li>nearest</li></ul><h3>Example (Node.js)</h3><pre>const client = new MongoClient(uri, {<br>  readPreference: &quot;secondaryPreferred&quot;<br>});</pre><p>⚠️ Reads from secondaries may return <strong>slightly stale data</strong>.</p><h3>Write Concerns</h3><p>Write concern defines <strong>how many nodes must acknowledge a write</strong>.</p><p>Options:</p><p>w:1Primary only</p><p>w:majorityMajority of nodes</p><p>w:0Fire-and-forget</p><h3>Example</h3><pre>db.users.insertOne(<br>  { name: &quot;Santosh&quot; },<br>  { writeConcern: { w: &quot;majority&quot;, j: true } }<br>);</pre><p>This guarantees:</p><ul><li>durability</li><li>replication safety</li><li>no rollback during failover</li></ul><h3>How Drivers Handle This Automatically</h3><p>MongoDB drivers (like Node.js) do a lot of work for you:</p><ul><li>discover replica set topology</li><li>detect the current Primary</li><li>reconnect during elections</li><li>retry safe writes</li></ul><h3>Connection string example</h3><pre>mongodb://node1,node2,node3/mydb?replicaSet=rs0&amp;retryWrites=true</pre><p>From the application’s point of view:</p><ul><li>writes just work</li><li>failover is transparent</li><li>no manual handling needed</li></ul><h3>Production Best Practices</h3><ul><li>Use <strong>3–5 nodes</strong></li><li>Use w:majority for critical data</li><li>Size oplog properly</li><li>Keep analytics off the Primary</li><li>Use priorities and hidden nodes</li><li>Avoid even number of nodes without an arbiter</li></ul><h3>Final Mental Model</h3><p>Oplog -&gt; Replication</p><p>Elections -&gt; Failover</p><p>Rollbacks -&gt; Consistency</p><p>Read Preference -&gt; Performance</p><p>Write Concern -&gt; Durability</p><p>Drivers -&gt; Automation</p><h3>Closing Thoughts</h3><p>Replica sets aren’t magic.</p><p>They are built on:</p><ul><li>ordered logs</li><li>majority consensus</li><li>clear trade-offs</li></ul><p>Once you understand these fundamentals, MongoDB becomes:</p><ul><li>predictable</li><li>easier to debug</li><li>safe to run in production</li></ul><p>If this post helped clarify replica sets, give it some claps 👏<br><strong>Part 2 is coming next — hands-on commands and screenshots.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c59885ade045" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering the Builder Pattern in JavaScript — Step-by-Step Guide]]></title>
            <link>https://medium.com/@guptasantosh327/mastering-the-builder-pattern-in-javascript-step-by-step-guide-861b54ddb34c?source=rss-2a5f8ebda53d------2</link>
            <guid isPermaLink="false">https://medium.com/p/861b54ddb34c</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[oops-concepts]]></category>
            <category><![CDATA[builder-pattern]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Santosh Gupta]]></dc:creator>
            <pubDate>Thu, 06 Nov 2025 13:03:14 GMT</pubDate>
            <atom:updated>2025-11-06T13:03:14.226Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering the Builder Pattern in JavaScript — Step-by-Step Guide</h3><h3>🔍 Introduction</h3><p>Start with a relatable problem.</p><blockquote><em>Have you ever found yourself creating objects with dozens of optional parameters — leading to long, confusing constructor calls?</em></blockquote><blockquote><em>The </em><strong><em>Builder Pattern</em></strong><em> solves this by letting you build complex objects step-by-step, improving readability and flexibility.</em></blockquote><h3>🧩 What Is the Builder Pattern?</h3><p>The <strong>Builder Pattern</strong> is a <em>creational design pattern</em> that separates the construction of a complex object from its representation.</p><p>It lets you create an object piece by piece — often using method chaining — and then “build” or “finalize” the result at the end.</p><p><strong>Key Benefits:</strong></p><ul><li>Makes object creation more readable.</li><li>Handles optional parameters cleanly.</li><li>Keeps constructors simple and maintainable.</li><li>Encourages immutability and encapsulation.</li></ul><h3>💡 Real-World Analogy</h3><p>Think of building a <strong>custom burger</strong> at a restaurant:</p><ul><li>You start with a base bun 🍔</li><li>Add cheese, lettuce, sauces, etc.</li><li>Finally, you say “I’m done” — and they build your burger.</li></ul><p>That’s exactly what the Builder Pattern does — it lets you construct something complex step-by-step.</p><h3>🧠 Example Without Builder</h3><p>Here’s what object creation <em>might</em> look like without a builder:</p><pre>class Car {<br>  constructor(make, model, year, color, engine, transmission, sunroof) {<br>    this.make = make;<br>    this.model = model;<br>    this.year = year;<br>    this.color = color;<br>    this.engine = engine;<br>    this.transmission = transmission;<br>    this.sunroof = sunroof;<br>  }<br>}<br>const car = new Car(&#39;Tesla&#39;, &#39;Model 3&#39;, 2025, &#39;Red&#39;, &#39;Electric&#39;, &#39;Automatic&#39;, true);</pre><p>This is <em>fine</em>, but imagine if there were 20 optional parameters. That’s not maintainable!</p><h3>🧱 Implementing the Builder Pattern</h3><p>Now let’s use the <strong>Builder Pattern</strong> to simplify this.</p><pre>class Car {<br>  constructor(builder) {<br>    this.make = builder.make;<br>    this.model = builder.model;<br>    this.year = builder.year;<br>    this.color = builder.color;<br>    this.engine = builder.engine;<br>    this.transmission = builder.transmission;<br>    this.sunroof = builder.sunroof;<br>  }<br>}<br><br>class CarBuilder {<br>  constructor(make, model) {<br>    this.make = make;<br>    this.model = model;<br>  }<br>  setYear(year) {<br>    this.year = year;<br>    return this;<br>  }<br>  setColor(color) {<br>    this.color = color;<br>    return this;<br>  }<br>  setEngine(engine) {<br>    this.engine = engine;<br>    return this;<br>  }<br>  setTransmission(transmission) {<br>    this.transmission = transmission;<br>    return this;<br>  }<br>  setSunroof(sunroof) {<br>    this.sunroof = sunroof;<br>    return this;<br>  }<br>  build() {<br>    return new Car(this);<br>  }<br>}<br>// Usage<br>const myCar = new CarBuilder(&#39;Tesla&#39;, &#39;Model 3&#39;)<br>  .setYear(2025)<br>  .setColor(&#39;Red&#39;)<br>  .setEngine(&#39;Electric&#39;)<br>  .setTransmission(&#39;Automatic&#39;)<br>  .setSunroof(true)<br>  .build();<br>console.log(myCar);</pre><p>✅ <strong>Advantages:</strong></p><ul><li>Clean and readable.</li><li>You can add/remove options easily.</li><li>Encourages method chaining for fluid syntax.</li></ul><h3>⚙️ Fluent Interface (Method Chaining)</h3><p>Notice how every setter returns this.<br> That’s known as a <strong>Fluent Interface</strong>, which makes the Builder Pattern elegant in JavaScript.</p><pre>const burger = new BurgerBuilder()<br>  .addBun(&#39;Sesame&#39;)<br>  .addPatty(&#39;Beef&#39;)<br>  .addCheese(&#39;Cheddar&#39;)<br>  .addSauce(&#39;BBQ&#39;)<br>  .build();</pre><h3>🪄 Bonus: Functional Builder Pattern (ES6+)</h3><p>With modern JavaScript, we can make the Builder Pattern even simpler using <strong>object literals and closures</strong>:</p><pre>const CarBuilder = () =&gt; {<br>  const car = {};<br>  return {<br>      setMake: make =&gt; (car.make = make, this),<br>      setModel: model =&gt; (car.model = model, this),<br>      setYear: year =&gt; (car.year = year, this),<br>      build: () =&gt; ({ ...car })<br>    };<br>};<br>const car = CarBuilder()<br>  .setMake(&#39;Tesla&#39;)<br>  .setModel(&#39;Model S&#39;)<br>  .setYear(2025)<br>  .build();<br>console.log(car);</pre><p>This style is great for lightweight use cases and demonstrates JS’s flexibility.</p><h3>🧩 When to Use the Builder Pattern</h3><p>Use it when:</p><ul><li>You have <strong>complex object construction</strong> with many optional parameters.</li><li>You want <strong>immutable, step-by-step object creation</strong>.</li><li>You want to avoid <strong>telescoping constructors</strong> (long parameter lists).</li></ul><p>Avoid it when:</p><ul><li>Object creation is simple (few parameters).</li><li>Performance overhead of extra classes isn’t justified.</li></ul><h3>🏁 Conclusion</h3><blockquote><em>The Builder Pattern is a powerful tool in your JavaScript design pattern toolkit — giving you flexibility, readability, and maintainability in object creation.<br></em>By mastering it, you can write more expressive, organized, and scalable code — especially for APIs, config objects, and UI components.</blockquote><h3>What’s Next ?</h3><blockquote><em>In the next article, we’ll explore how the </em><strong><em>Factory Pattern</em></strong><em> complements the Builder Pattern — helping you manage object creation logic at scale.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=861b54ddb34c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>