<?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"><channel><title><![CDATA[Harshit Pundir's Blog]]></title><description><![CDATA[Harshit Pundir's Blog]]></description><link>https://blog.harshitpundir.tech</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 00:21:08 GMT</lastBuildDate><atom:link href="https://blog.harshitpundir.tech/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding Multi-Tenancy]]></title><description><![CDATA[When you start learning software development, you often hear words that sound scary at first.One of those words is multi-tenancy.
Don’t worry.This concept is actually very simple.
In this blog, we’ll understand:

What multi-tenancy really means

Why ...]]></description><link>https://blog.harshitpundir.tech/understanding-multi-tenancy</link><guid isPermaLink="true">https://blog.harshitpundir.tech/understanding-multi-tenancy</guid><category><![CDATA[Multi tenancy]]></category><category><![CDATA[saas development ]]></category><dc:creator><![CDATA[Harshit Pundir]]></dc:creator><pubDate>Fri, 06 Feb 2026 20:33:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1770409811852/a7512f48-4715-44e3-8ed1-c2b516ac084b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you start learning software development, you often hear words that sound scary at first.<br />One of those words is <strong><em>multi-tenancy</em>.</strong></p>
<p>Don’t worry.<br />This concept is actually <strong>very simple</strong>.</p>
<p>In this blog, we’ll understand:</p>
<ul>
<li><p>What multi-tenancy really means</p>
</li>
<li><p>Why is it used in real applications</p>
</li>
<li><p>How big companies use it</p>
</li>
<li><p>Different ways to implement it</p>
</li>
<li><p>Pros and cons of each approach</p>
</li>
</ul>
<h1 id="heading-what-is-multi-tenancy">What is Multi-Tenancy?</h1>
<p>Multi-tenancy means:</p>
<blockquote>
<p><strong>One application serving many customers at the same time — safely and separately.</strong></p>
</blockquote>
<p>Each customer is called a <strong>tenant</strong>.</p>
<p>All tenants:</p>
<ul>
<li><p>Use the <strong>same application</strong></p>
</li>
<li><p>Run on the <strong>same infrastructure</strong></p>
</li>
<li><p>Share the <strong>same code</strong></p>
</li>
</ul>
<p>But still:</p>
<ul>
<li><p><strong>Their data is completely private</strong></p>
</li>
<li><p><strong>One tenant can never see another tenant’s data</strong></p>
</li>
</ul>
<p>That’s the most important rule of multi-tenancy.</p>
<h1 id="heading-a-simple-real-life-example-apartment-building">A Simple Real-Life Example (Apartment Building)</h1>
<p>Imagine an <strong>apartment building</strong> 🏢</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770408484185/c5fa0d04-244d-49f6-aaf5-135e023369c4.jpeg" alt class="image--center mx-auto" /></p>
<ul>
<li><p>The <strong>building</strong> = the application</p>
</li>
<li><p>Each <strong>flat/apartment</strong> = one tenant</p>
</li>
</ul>
<p>Everyone in the building:</p>
<ul>
<li><p>Uses the same lift</p>
</li>
<li><p>Uses the same water supply</p>
</li>
<li><p>Uses the same electricity system</p>
</li>
</ul>
<p>But still:</p>
<ul>
<li><p>You cannot enter someone else’s flat</p>
</li>
<li><p>Your personal things stay private</p>
</li>
<li><p>Your neighbour cannot see what’s inside your home</p>
</li>
</ul>
<p>This is <strong>exactly</strong> how multi-tenancy works in software.</p>
<p>Shared system, but <strong>private spaces</strong>.</p>
<h1 id="heading-why-do-we-need-multi-tenancy">Why Do We Need Multi-Tenancy?</h1>
<p>Imagine if every customer needed:</p>
<ul>
<li><p>A separate application</p>
</li>
<li><p>Separate servers</p>
</li>
<li><p>Separate codebase</p>
</li>
</ul>
<p>That would be:</p>
<ul>
<li><p>Very expensive</p>
</li>
<li><p>Hard to maintain</p>
</li>
<li><p>Impossible to scale</p>
</li>
</ul>
<p>Multi-tenancy solves this problem by:</p>
<ul>
<li><p>Sharing resources</p>
</li>
<li><p>Reducing cost</p>
</li>
<li><p>Making systems scalable</p>
</li>
<li><p>Allowing thousands or millions of users</p>
</li>
</ul>
<p>That’s why <strong>almost every modern SaaS product</strong> uses multi-tenancy.</p>
<h1 id="heading-real-world-examples-of-multi-tenancy">Real-World Examples of Multi-Tenancy</h1>
<p>Let’s look at some apps you already know.</p>
<h2 id="heading-shopify">🛒 Shopify</h2>
<p>Thousands of businesses create their online stores using Shopify.</p>
<ul>
<li><p>All stores run on the <strong>same Shopify platform</strong></p>
</li>
<li><p>Same backend code</p>
</li>
<li><p>Same servers</p>
</li>
</ul>
<p>But:</p>
<ul>
<li><p>One store cannot see another store’s customers</p>
</li>
<li><p>Products, orders, and payments are fully isolated</p>
</li>
</ul>
<p>Each store = one tenant.</p>
<h2 id="heading-github">💻 GitHub</h2>
<p>GitHub uses <strong>organizations</strong>.</p>
<ul>
<li><p>One organization = one tenant</p>
</li>
<li><p>Repositories are isolated per organization</p>
</li>
<li><p>Permissions are scoped correctly</p>
</li>
</ul>
<p>This is multi-tenancy in action.</p>
<h1 id="heading-how-is-multi-tenancy-implemented">How is Multi-Tenancy Implemented?</h1>
<p>There are <strong>two common ways</strong> to build multi-tenant systems.</p>
<p>Each has its own advantages and disadvantages.</p>
<h2 id="heading-approach-1-separate-database-for-each-tenant">Approach 1: Separate Database for Each Tenant</h2>
<h3 id="heading-how-it-works">How It Works</h3>
<ul>
<li><p>Every tenant gets <strong>its own database</strong></p>
</li>
<li><p>If you have:</p>
<ul>
<li><p>10 customers → 10 databases</p>
</li>
<li><p>1 million customers → 1 million databases</p>
</li>
</ul>
</li>
</ul>
<p>Each database is completely independent.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770408794713/afb7f459-e847-40ae-b4dd-121a8ba4215c.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-why-this-is-good">Why This is Good</h3>
<p>✅ Very strong data isolation<br />✅ Almost zero chance of data leakage<br />✅ Easy to reason about security<br />✅ Simple queries (no filtering needed)</p>
<h3 id="heading-why-this-is-problematic">Why This is Problematic</h3>
<p>❌ Hard to manage at a large scale<br />❌ Creating and maintaining databases is expensive<br />❌ Small tenants waste resources<br />❌ Deployment and migrations become complex</p>
<p>This approach is usually used when:</p>
<ul>
<li><p>Security is <strong>extremely critical</strong></p>
</li>
<li><p>The number of tenants is limited</p>
</li>
<li><p>Each tenant is large.</p>
</li>
</ul>
<h2 id="heading-approach-2-shared-database-with-tenant-id-row-level-separation">Approach 2: Shared Database with Tenant ID (Row-Level Separation)</h2>
<h3 id="heading-how-it-works-1">How It Works</h3>
<ul>
<li><p>All tenants share <strong>one database</strong></p>
</li>
<li><p>Every table has a <code>tenant_id</code> column</p>
</li>
<li><p>Each row belongs to one tenant</p>
</li>
</ul>
<p>Example:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770409044581/06750642-4b46-4f51-859e-bfe976fe652a.jpeg" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770409149287/c355bba4-2a79-43fa-bd20-bc90a29af739.jpeg" alt class="image--center mx-auto" /></p>
<p>When a tenant makes a request:</p>
<ul>
<li>System fetches only rows with <strong>that tenant’s ID</strong></li>
</ul>
<h3 id="heading-why-this-is-good-1">Why This is Good</h3>
<p>✅ Very easy to scale<br />✅ Only one database to manage<br />✅ New tenant = just new rows<br />✅ Better resource utilization</p>
<p>This is the <strong>most common approach</strong> in SaaS apps.</p>
<h3 id="heading-why-this-is-risky">Why This is Risky</h3>
<p>❌ One small bug can leak data<br />❌ Every query must be written carefully<br />❌ Missing tenant filter = security issue<br />❌ Requires strong testing and discipline</p>
<p>This approach works best when:</p>
<ul>
<li><p>You have many tenants</p>
</li>
<li><p>You want fast onboarding</p>
</li>
<li><p>Your engineering practices are strong</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770409717368/86d53448-9e9e-466b-9e03-d423c9638688.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-which-approach-should-you-choose">Which Approach Should You Choose?</h2>
<p>There is <strong>no single correct answer</strong>.</p>
<p>It depends on:</p>
<ul>
<li><p>Number of tenants</p>
</li>
<li><p>Size of each tenant</p>
</li>
<li><p>Security requirements</p>
</li>
<li><p>Cost constraints</p>
</li>
<li><p>Engineering maturity</p>
</li>
</ul>
<p>Many companies even use <strong>hybrid approaches</strong>:</p>
<ul>
<li><p>Small tenants → shared database</p>
</li>
<li><p>Large tenants → separate databases</p>
</li>
</ul>
<h2 id="heading-why-every-developer-should-understand-multi-tenancy">Why Every Developer Should Understand Multi-Tenancy</h2>
<p>If you want to build:</p>
<ul>
<li><p>SaaS products</p>
</li>
<li><p>Scalable backends</p>
</li>
<li><p>Real-world applications</p>
</li>
</ul>
<p>Then, multi-tenancy is <strong>not optional knowledge</strong>.</p>
<p>It teaches you:</p>
<ul>
<li><p>Data isolation</p>
</li>
<li><p>Security thinking</p>
</li>
<li><p>Scalable design</p>
</li>
<li><p>Real production problems</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Serverless Architecture for Backend]]></title><description><![CDATA[What are Backend Server?
As a developer, you probably build the frontend app or web app using basic Technology like HTML, CSS, Javascript, and React (Javascript library) you can easily deploy them using famous platforms like Vercel, Netlify, and many...]]></description><link>https://blog.harshitpundir.tech/serverless-architecture-for-backend</link><guid isPermaLink="true">https://blog.harshitpundir.tech/serverless-architecture-for-backend</guid><category><![CDATA[serverless]]></category><category><![CDATA[serverless framework]]></category><category><![CDATA[serverless computing]]></category><category><![CDATA[serverless consulting]]></category><category><![CDATA[Serverless Architecture]]></category><dc:creator><![CDATA[Harshit Pundir]]></dc:creator><pubDate>Tue, 12 Mar 2024 04:34:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1710217905179/64fd5440-f81a-4907-8929-94c40874581d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-are-backend-server"><strong>What are Backend Server?</strong></h3>
<p>As a developer, you probably build the frontend app or web app using basic Technology like HTML, CSS, Javascript, and React (Javascript library) you can easily deploy them using famous platforms like Vercel, Netlify, and many more. but in the case of deploying the backend server is like <strong>a snowball's chance in Hell.</strong></p>
<p>If you know some Backend then you might use <code>express</code> to create the Backend server and run it usually <code>node index.js</code> which starts a process on a certain port whatever you defined.</p>
<p><strong>If you want to deploy it on the internet, there are a few ways-</strong></p>
<p><strong>i. AWS ii. GCP [Google Cloud Platform Services] iii.Azure iv. Cloudflare</strong></p>
<h2 id="heading-how">HOW?</h2>
<ol>
<li><p>Rent a VM (Virtual Machine) and deploy your app.</p>
</li>
<li><p>Put it in an Auto-scaling group</p>
</li>
<li><p>Deploy it in a Kubernetes cluster</p>
</li>
</ol>
<p><strong>Don't worry if don't get any idea about these we will discuss everything further.</strong></p>
<p><strong>Everything and Everyone has pros and cons similar to the downside of this is-</strong></p>
<ol>
<li><p>Taking Care of how/when to scale.</p>
</li>
<li><p>You have to pay the base cost even if no one is visiting your website</p>
</li>
<li><p>Monitoring various servers to make sure no server is down</p>
</li>
</ol>
<h3 id="heading-what-if-you-could-just-write-the-code-and-someone-else-could-take-care-of-all-of-these-problems">What if, you could just write the code and someone else could take care of all of these problems?</h3>
<h1 id="heading-what-areserverless-backends"><strong>What are</strong><code>serverless</code> Backends</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709401677691/baad795a-bd2f-4468-a144-aee21d692a18.png?auto=compress,format&amp;format=webp" alt /></p>
<h3 id="heading-definition"><strong>Definition:</strong></h3>
<p>What if you could just write your <code>express routes</code> and run a command. The app would automatically</p>
<ol>
<li><p>Deploy</p>
</li>
<li><p>Autoscale</p>
</li>
<li><p>Charge you on a <code>per request</code> basis (rather than you paying for VMs)</p>
</li>
</ol>
<p>As I told you everything in this world has pros and cons so this also has some cons but these cons or problems are very important to know.</p>
<ol>
<li><h3 id="heading-more-expensive-at-scale">More Expensive at scale: -</h3>
</li>
</ol>
<p>As the backend system grows bigger, it costs more money to manage and maintain it properly.</p>
<ol start="2">
<li><h3 id="heading-cold-start-problem">Cold start problem: -</h3>
</li>
</ol>
<p>"Delayed response when serverless function or microservice is inactive or newly initialized."</p>
<p><strong>There are many famous backend serverless providers -</strong></p>
<details><summary>AWS Lambda</summary><div data-type="detailsContent"></div></details>

<p><a target="_blank" href="https://aws.amazon.com/pm/lambda/?trk=5cc83e4b-8a6e-4976-92ff-7a6198f2fe76&amp;sc_channel=ps&amp;ef_id=CjwKCAiAt5euBhB9EiwAdkXWO-i-th4J3onX9ji-tPt_JmsBAQJLWYN4hzTF0Zxb084EkUBxSCK5vhoC-1wQAvD_BwE:G:s&amp;s_kwcid=AL!4422!3!651612776783!e!!g!!aws%20lambda!19828229697!143940519541"><strong>https://aws.amazon.com/pm/lambda/?trk=5cc83e4b-8a6e-4976-92ff-7a6198f2fe76&amp;sc_channel=ps&amp;ef_id=CjwKCAiAt5euBhB9EiwAdkXWO-i-th4J3onX9ji-tPt_JmsBAQJLWYN4hzTF0Zxb084EkUBxSCK5vhoC-1wQAvD_BwE:G:s&amp;s_kwcid=AL!4422!3!651612776783!e!!g!!aws lambda!19828229697!143940519541</strong></a></p>
<details><summary>Google Cloud Functions</summary><div data-type="detailsContent"></div></details>

<p><a target="_blank" href="https://firebase.google.com/docs/functions"><strong>https://firebase.google.com/docs/functions</strong></a></p>
<details><summary>Cloudflare Workers</summary><div data-type="detailsContent"></div></details>

<p><a target="_blank" href="https://workers.cloudflare.com/"><strong>https://workers.cloudflare.com/</strong></a></p>
<p>But we will use Cloud-flare for this :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709402750440/b5df9fda-c0db-4eb9-a9bb-ae769c72340d.png?auto=compress,format&amp;format=webp" alt /></p>
<p>Just go on the Cloudflare website and sign up if you are new you will get to see something like this. before we proceed there is a big question that arises which is:-</p>
<h1 id="heading-when-should-you-use-a-serverless-architecture"><strong>When should you use a serverless architecture?</strong></h1>
<ol>
<li><p><strong>When you want Quick Launch:</strong></p>
<ul>
<li>Serverless lets you start your app fast without server setup worries. It's like moving into a ready-to-use office.</li>
</ul>
</li>
<li><p><strong>When you want Automatic Scaling:</strong></p>
<ul>
<li>It adjusts to traffic changes automatically. Think of it as a store that expands or shrinks based on customers, saving costs.</li>
</ul>
</li>
<li><p><strong>When you want Cost Optimization:</strong></p>
<ul>
<li>You pay only when your code runs, making it cost-effective for low-traffic apps. It's like paying for electricity only when you use it, keeping bills low.</li>
</ul>
</li>
</ol>
<h3 id="heading-few-senior-developers-want-to-know-how-cloudflare-workers-work">Few senior developers want to know how Cloudflare workers work.</h3>
<p>For detailed blog post click here:- <a target="_blank" href="https://developers.cloudflare.com/workers/reference/how-workers-works/#:~:text=Though%20Cloudflare%20Workers%20behave%20similarly,used%20by%20Chromium%20and%20Node"><strong>Blog on Workers</strong></a></p>
<p>they can read this blog for more detail i also mentioned some important glimpses from the blog:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709403773795/27c2a923-68e3-40d6-8fac-0746e4760484.png?auto=compress,format&amp;format=webp" alt /></p>
<p>I think You know enough to start using Cloudflare. Don't worry, just follow my steps carefully, and you'll learn how to set up the backend without any problems.</p>
<ul>
<li><p>Create a directory with a name whatever you want suppose we created a directory with name practice.</p>
</li>
<li><p>Open this directory in the code Editor whatever you use</p>
</li>
<li><p>Open the terminal in the code editor and write this command for initializing the Cloudflare init the command is:-</p>
<p>  <strong>COPY</strong></p>
<p>  <strong>COPY</strong></p>
<pre><code class="lang-basic">     npm create cloudflare
</code></pre>
</li>
</ul>
<p>now select the "Hello World" workers as we just Learning.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709404685701/5c1afd00-d1a3-41cf-839c-0eac9047de96.png?auto=compress,format&amp;format=webp" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709404746315/399c9a3f-4aa5-40cc-bc39-51c37f4d04db.png?auto=compress,format&amp;format=webp" alt /></p>
<p>As I know the typescript I preferred to use typescript. if you don't then relax there is not to worry</p>
<p><strong><em>After that, they ask you:</em></strong></p>
<ul>
<li><p><strong>Do you want to deploy your application?</strong> Select the NO because we will deploy the backend using <code>npm run deploy</code></p>
</li>
<li><p><strong>Explore package.json dependencies</strong></p>
<p>  <strong>COPY</strong></p>
<p>  <strong>COPY</strong></p>
<pre><code class="lang-basic">    <span class="hljs-string">"wrangler"</span>: <span class="hljs-string">"^3.0.0"</span>
</code></pre>
<p>  Notice <code>express</code> there is no dependency on there</p>
</li>
<li><p><strong>Start the worker locally and write this in the directory where package.json exists</strong></p>
<p>  <strong>COPY</strong></p>
<p>  <strong>COPY</strong></p>
<pre><code class="lang-basic">    npm <span class="hljs-keyword">run</span> dev
</code></pre>
<p>  After that, your terminal will look like this now just press ctrl and on the localhost:8787:-</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709405486182/b449a7c0-922e-4a87-beec-f586b5e285c3.png?auto=compress,format&amp;format=webp" alt /></p>
<p>  You can see you are directed to the browser where Hello World is written.</p>
</li>
<li><p>Open src file you'll see this:</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709406033049/d7c25d85-1356-4220-9e92-bf1b2cdaed59.png?auto=compress,format&amp;format=webp" alt /></p>
<h3 id="heading-question-where-is-the-express-code-http-server"><strong>Question - Where is the express code? HTTP Server?</strong></h3>
<p>  Cloudflare expects you to just write the logic to handle a request. Creating an HTTP server on top is handled by Cloudflare</p>
</li>
<li><h3 id="heading-question-how-can-i-dorouting"><strong>Question - How can I do</strong><code>routing</code> ?</h3>
<p>  In express, routing is done as follows -</p>
<p>  <strong>COPY</strong></p>
<p>  <strong>COPY</strong></p>
<pre><code class="lang-basic">    import express from <span class="hljs-string">"express"</span>
    const app = express();

    app.<span class="hljs-keyword">get</span>(<span class="hljs-string">"/route"</span>, (req, res) =&gt; {
        // handles a <span class="hljs-keyword">get</span> request <span class="hljs-keyword">to</span> /route
    });
</code></pre>
<p>  This is how you can do the same in the Cloudflare environment.</p>
<p>  <strong>COPY</strong></p>
<p>  <strong>COPY</strong></p>
<pre><code class="lang-basic">    export default {
        async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise&lt;Response&gt; {
            console.<span class="hljs-keyword">log</span>(request.body);
            console.<span class="hljs-keyword">log</span>(request.headers);

            <span class="hljs-keyword">if</span> (request.method === <span class="hljs-string">"GET"</span>) {
                <span class="hljs-keyword">return</span> Response.json({
                    message: <span class="hljs-string">"you sent a get request"</span>
                });
            } <span class="hljs-keyword">else</span> {
                <span class="hljs-keyword">return</span> Response.json({
                    message: <span class="hljs-string">"you did not send a get request"</span>
                });
            }
        },
    };
</code></pre>
<p>  Don't worry if you see this code; it's just for reading purposes. We won't use it. This code shows how to create a GET request using Cloudflare Workers, but we won't use it because Cloudflare Workers use their library, not Node.js or any other common libraries. Writing code with this library can be challenging.</p>
</li>
<li><p>Lets Deploying a worker</p>
</li>
</ul>
<p>Now that you have written a basic HTTP server, let’s get to the most interesting bit — <code>Deploying it on the internet</code></p>
<p>We use Wrangler Dont worry I'll tell you</p>
<p>Step 1 Log in to Cloudflare via the Command Line Interface <code>npx wrangler login</code> Nothing just type this in the terminal of the code editor where the project is going on.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709407099276/e2cdc4c2-5e9d-4d69-b3f2-72697bf077df.png?auto=compress,format&amp;format=webp" alt /></p>
<p>you'll see something like this.</p>
<p>Step 2 Deploy Your Worker:</p>
<p><strong>COPY</strong></p>
<p><strong>COPY</strong></p>
<pre><code class="lang-basic">npm <span class="hljs-keyword">run</span> deploy
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709407183250/608eddb3-5740-4c55-a1de-611910039c62.png?auto=compress,format&amp;format=webp" alt /></p>
<p>After this, you'll see something like this</p>
<hr />
<p><strong>This is optional and just to know:-</strong></p>
<h3 id="heading-assigning-a-custom-domain"><strong>Assigning a custom domain</strong></h3>
<p>You have to buy a plan to be able to do this</p>
<p>You also need to buy the domain on Cloudflare/transfer the domain to Cloudflare</p>
<p><img src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F085e8ad8-528e-47d7-8922-a23dc4016453%2F2cde6fd6-3b5e-40db-92dd-8dd42d78072b%2FScreenshot_2024-02-10_at_4.06.21_AM.jpg?table=block&amp;id=48d79027-bffe-4c5a-a308-582671ab0098&amp;cache=v2" alt="notion image" /></p>
<hr />
<p>Come back to the topic If you now go back to the website it will show you this means that u deployed your application for now ignore my-app the app we deploy is calm-sun-10b3</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709407742682/39f44491-d9b1-4387-9a48-d4b406716c81.png?auto=compress,format&amp;format=webp" alt /></p>
<ul>
<li><strong>Now come back to the very important question which is whether we always use this challenging worker syntax or we have something else to tackle this problem.</strong></li>
</ul>
<h3 id="heading-why-cant-we-use-express">Why can’t we use express?</h3>
<p>Now you might be thinking <strong>Why does Cloudflare doesn’t start with a simple express boilerplate?</strong> the answer to this Question is very simple:</p>
<ul>
<li><strong>Express heavily relies on Node.js</strong></li>
</ul>
<p><strong>The answer to this big question is:</strong></p>
<h3 id="heading-using-hono"><strong>Using Hono</strong></h3>
<p>You must read this Because this will give you the answer to all the questions you have in your mind:-</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709408397863/73f695b3-974d-4635-b66a-10329e3441c4.png?auto=compress,format&amp;format=webp" alt /></p>
<p><strong>What runtime does it support:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709408552394/4a194390-f7bf-41a1-a0a4-25339d9a6560.png?auto=compress,format&amp;format=webp" alt /></p>
<p><strong>Using Hono is easy:-</strong></p>
<h3 id="heading-initialize-a-new-app">Initialize a new app</h3>
<p><strong>COPY</strong></p>
<p><strong>COPY</strong></p>
<pre><code class="lang-basic">npm create hono@latest my-app
</code></pre>
<ol>
<li>Move to <code>my-app</code> and install the dependencies.</li>
</ol>
<p><strong>COPY</strong></p>
<p><strong>COPY</strong></p>
<pre><code class="lang-basic">cd my-app
npm i
</code></pre>
<ol>
<li>Hello World</li>
</ol>
<p><strong>COPY</strong></p>
<p><strong>COPY</strong></p>
<pre><code class="lang-basic">import { Hono } from <span class="hljs-comment">'hono'</span>
const app = <span class="hljs-keyword">new</span> Hono()

app.<span class="hljs-keyword">get</span>(<span class="hljs-comment">'/', (c) =&gt; c.text('Hello Cloudflare Workers!'))</span>

export default app
</code></pre>
<h3 id="heading-getting-inputs-from-the-user"><strong>Getting inputs from the user</strong></h3>
<p><strong>COPY</strong></p>
<p><strong>COPY</strong></p>
<pre><code class="lang-basic">import { Hono } from <span class="hljs-comment">'hono'</span>

const app = <span class="hljs-keyword">new</span> Hono()

app.post(<span class="hljs-comment">'/', async (c) =&gt; {</span>
  const body = await c.req.json()
  console.<span class="hljs-keyword">log</span>(body);
  console.<span class="hljs-keyword">log</span>(c.req.header(<span class="hljs-string">"Authorization"</span>));
  console.<span class="hljs-keyword">log</span>(c.req.query(<span class="hljs-string">"param"</span>));

  <span class="hljs-keyword">return</span> c.text(<span class="hljs-comment">'Hello Hono!')</span>
})

export default app
</code></pre>
<p><em>If you are here and learning the serverless Backend so you know what is Postman and how to use it now just do one thing.</em></p>
<ul>
<li><p>Go on the Postman and write the localhost(URL) above</p>
</li>
<li><p>Select the POST from the options</p>
</li>
<li><p>Write any value in the headers with the key Authorization and query param.</p>
</li>
<li><p>Now click on the Send Button.</p>
</li>
<li><p>You can see the output in the console if there is an error try to fix it.</p>
</li>
</ul>
<h3 id="heading-deploying"><strong>Deploying</strong></h3>
<p>Make sure you’re logged into Cloudflare (<code>wrangler login</code>)</p>
<p><strong>COPY</strong></p>
<p><strong>COPY</strong></p>
<pre><code class="lang-basic">npm <span class="hljs-keyword">run</span> deploy
</code></pre>
<h1 id="heading-middlewares"><strong>Middlewares</strong></h1>
<h3 id="heading-creating-a-simple-auth-middleware"><strong>Creating a simple auth middleware</strong></h3>
<p>Middleware is very important in the backend this is how you define the middleware in the backend.</p>
<p><strong>COPY</strong></p>
<p><strong>COPY</strong></p>
<pre><code class="lang-basic">import { Hono, <span class="hljs-keyword">Next</span> } from <span class="hljs-comment">'hono'</span>
import { Context } from <span class="hljs-comment">'hono/jsx';</span>

const app = <span class="hljs-keyword">new</span> Hono()

app.use(async (c, <span class="hljs-keyword">next</span>) =&gt; {
  <span class="hljs-keyword">if</span> (c.req.header(<span class="hljs-string">"Authorization"</span>)) {
    // Do validation
    await <span class="hljs-keyword">next</span>()
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-keyword">return</span> c.text(<span class="hljs-string">"You dont have acces"</span>);
  }
})

app.<span class="hljs-keyword">get</span>(<span class="hljs-comment">'/', async (c) =&gt; {</span>
  const body = await c.req.parseBody()
  console.<span class="hljs-keyword">log</span>(body);
  console.<span class="hljs-keyword">log</span>(c.req.header(<span class="hljs-string">"Authorization"</span>));
  console.<span class="hljs-keyword">log</span>(c.req.query(<span class="hljs-string">"param"</span>));

  <span class="hljs-keyword">return</span> c.json({msg: <span class="hljs-string">"as"</span>})
})

export default app
</code></pre>
<p>Notice you have to return the <code>c.text</code> value.</p>
<h3 id="heading-as-you-can-see-coding-in-hono-is-quite-similar-to-using-express-hono-is-an-excellent-library-for-writing-code-in-cloudflare-workers-and-deploying-the-backend-that-wraps-up-this-blog-thank-you-for-reading">"As you can see, coding in Hono is quite similar to using Express. Hono is an excellent library for writing code in Cloudflare Workers and deploying the backend. That wraps up this blog. Thank you for reading!".</h3>
]]></content:encoded></item><item><title><![CDATA[Postgres 🐘]]></title><description><![CDATA[I know that you know there are a few types of databases and the most famous ones are SQL and NoSQL.
Most students prefer to learn SQL databases after they learn the NoSQL like MongoDB which is good to learn NoSQL database which is a very good approac...]]></description><link>https://blog.harshitpundir.tech/postgres</link><guid isPermaLink="true">https://blog.harshitpundir.tech/postgres</guid><category><![CDATA[Docker]]></category><category><![CDATA[PostgreSQL]]></category><category><![CDATA[SQL]]></category><category><![CDATA[NoSQL]]></category><category><![CDATA[mongoose]]></category><category><![CDATA[MongoDB]]></category><category><![CDATA[postgres]]></category><category><![CDATA[prisma]]></category><dc:creator><![CDATA[Harshit Pundir]]></dc:creator><pubDate>Wed, 06 Mar 2024 13:35:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1709732335337/57a11594-ac0c-46db-90e4-50e2773d6590.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I know that you know there are a few types of databases and the most famous ones are SQL and NoSQL.</p>
<p>Most students prefer to learn SQL databases after they learn the NoSQL like MongoDB which is good to learn NoSQL database which is a very good approach but if it's your first time learning database it's alright I am here to explain you each and everything you have to know about.</p>
<p>but before let's see what is the difference between the SQL and NoSQL databases.</p>
<ul>
<li><h4 id="heading-nosql-databases"><strong>NoSQL databases</strong></h4>
</li>
</ul>
<ol>
<li><p>Store data in a <code>schema-less</code> fashion. Extremely lean and fast way to store data.</p>
</li>
<li><p>Examples - MongoDB,</p>
</li>
</ol>
<h4 id="heading-sql-databases"><strong>SQL databases</strong></h4>
<ol>
<li><p>Stores data in the form of rows</p>
</li>
<li><p>Most full-stack applications will use this</p>
</li>
<li><p>Examples - MySQL and, Postgres</p>
</li>
</ol>
<p>but you see what is wrong with the NoSQL database and why most of the full stack app uses the SQL database</p>
<h3 id="heading-why-not-nosql">Why not NoSQL?</h3>
<p>its schemaless property makes it ideal for bootstrapping the project fast,<br />But as your app grows, this property makes it very easy for data to get <code>curropted</code></p>
<h3 id="heading-what-is-schemaless">What is Schemaless?</h3>
<p>Different rows can have different <code>schema</code> (keys/types)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709718208175/f04f079c-2464-42c2-b97b-2d587e3024fc.png" alt class="image--center mx-auto" /></p>
<h4 id="heading-xcpckg">**</h4>
<p>Problems?**</p>
<ol>
<li><p>This can lead to inconsistent database</p>
</li>
<li><p>Can cause runtime errors</p>
</li>
<li><p>Is too flexible for an app that needs strictness</p>
</li>
</ol>
<h4 id="heading-upsides"><strong>Upsides?</strong></h4>
<ol>
<li><p>Can move very fast</p>
</li>
<li><p>Can change schema very easily</p>
</li>
</ol>
<p>There is a point above <em>Is too flexible for an app that needs strictness</em> this principle is also applicable in real life and in the coding for that we are using typescript instead of javascript. My blog on the typescript is coming on 10 March 2024 on my blog channel. let's come back to the topic.</p>
<p>till now we have discussed how many types of databases and what is the problem with NoSQL, let me discuss solid reasons for :</p>
<h3 id="heading-why-sql">Why SQL?</h3>
<p>SQL databases have a strict schema. They require you to</p>
<ol>
<li><p>Define your schema</p>
</li>
<li><p>Put in data that follows that schema</p>
</li>
<li><p>Update the schema as your app changes and perform <code>migrations</code></p>
</li>
</ol>
<p><em>if you already know the NoSQL database then you can easily understand the points that are given below:</em></p>
<p>So there are 4 parts when using an SQL database (not connecting it to Node.js, just running it and putting data in it)</p>
<ol>
<li><p>Running the database.</p>
</li>
<li><p>Using a library that lets you connect and put data in it.</p>
</li>
<li><p>Creating a table and defining it’s <code>schema</code>.</p>
</li>
<li><p>Run queries on the database to interact with the data (Insert/Update/Delete)</p>
</li>
</ol>
<p>if you don't know about them then don't worry we just do in the second point we said that</p>
<p>we are gonna use a library to perform the CRUD operation in the SQL database if you don't know what is CRUD then it simply means Create Read Update and Delete. from the database.</p>
<p>Okay I think this is enough to explain the SQL so let's move to</p>
<h1 id="heading-creating-a-database"><strong>Creating a database</strong></h1>
<p>You can go and easily generate the Postgres string for the database from neon db for now I am going to do it locally by using docker no need to install Postgres locally because it takes time and data for this practice session and learning session I am going to generate the Postgres string using Docker so let's get start:</p>
<ul>
<li>Using docker locally</li>
</ul>
<p>if you also have docker locally then follow this command in your terminal for generating the container of postgres locally.</p>
<pre><code class="lang-plaintext">docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
</code></pre>
<p>in this command POSTGRES_PASSWORD=mysecretpassword you can write any password you want to secure your database. it depends upon you.</p>
<h4 id="heading-connection-string"><strong>Connection String</strong></h4>
<p>Now modify the connecting string as per your password and your string is ready which helps you to connect the database and your backend.</p>
<pre><code class="lang-plaintext">postgresql://postgres:mysecretpassword@localhost:5432/postgres?sslmode=disable
</code></pre>
<ul>
<li>Using neondb</li>
</ul>
<p><a target="_blank" href="https://neon.tech/">https://neon.tech/ is a decent service that</a> lets you create a server.</p>
<p><img src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F085e8ad8-528e-47d7-8922-a23dc4016453%2Fb7ee7eea-328e-4b37-8481-0afb51676e7b%2FScreenshot_2024-02-02_at_9.45.53_PM.png?table=block&amp;id=f089c2e4-7756-4532-a7df-ca4a482138ac&amp;cache=v2" alt="notion image" /></p>
<p><img src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F085e8ad8-528e-47d7-8922-a23dc4016453%2F18fc29c5-b324-4e91-bdd0-549d4977561b%2FScreenshot_2024-02-02_at_9.46.01_PM.png?table=block&amp;id=2d1bd758-fd33-4bef-95ae-47f826076991&amp;cache=v2" alt="notion image" /></p>
<h4 id="heading-connection-string-1"><strong>Connection String</strong></h4>
<p>Your connecting string will look like something this but the password and username will change as per your command</p>
<pre><code class="lang-plaintext">postgresql://username:password@ep-broken-frost-69135494.us-east-2.aws.neon.tech/calm-gobbler-41_db_2253874
</code></pre>
<h1 id="heading-using-a-library-that-lets-you-connect-and-put-data-in-it"><strong>Using a library that lets you connect and put data in it.</strong></h1>
<h3 id="heading-1-psql"><strong>1. psql</strong></h3>
<p><code>psql</code> is a terminal-based front-end to PostgreSQL. It provides an interactive command-line interface to the PostgreSQL (or TimescaleDB) database. With SQL, you can type in queries interactively, issue them to PostgreSQL, and see the query results.</p>
<h4 id="heading-how-to-connect-to-your-database"><strong>How to connect to your database?</strong></h4>
<p>psql Comes bundled with Postgresql. You don’t need it for this tutorial. We will directly be communicating with the database from Node.js</p>
<pre><code class="lang-plaintext">psql -h p-broken-frost-69135494.us-east-2.aws.neon.tech -d database1 -U 100xdevs
</code></pre>
<h3 id="heading-2-pg"><strong>2. pg</strong></h3>
<p><code>pg</code> is a <code>Node.js</code> library that you can use in your backend app to store data in the Postgres DB (similar to <code>mongoose</code>). We will be installing this eventually in our app.</p>
<p>for now, just read them both if you are getting confused then don't worry we will discover them deeply in further blog for now lets:</p>
<h1 id="heading-creating-a-table-and-defining-itsschema"><strong>Creating a table and defining it’s</strong><code>schema</code>.</h1>
<h3 id="heading-tables-in-sql"><strong>Tables in SQL</strong></h3>
<p>A single database can have multiple tables inside. Think of them as collections in a MongoDB database.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709727244515/745dd71e-b973-44b6-aed9-9ba68433db93.png" alt class="image--center mx-auto" /></p>
<p>Until now we just have just database that we can interact with. The next step in the case of postgres is to define <code>schema</code> of your tables. To create a table, the command to run is -</p>
<pre><code class="lang-plaintext">CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    username VARCHAR(50) UNIQUE NOT NULL,
    email VARCHAR(255) UNIQUE NOT NULL,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
</code></pre>
<ol>
<li><p>CREATE TABLE USER: this command initiates the creation of a new table in the database named user.</p>
</li>
<li><p>id SERIAL PRIMARY KEY:</p>
<ul>
<li><p><code>id</code>: The name of the first column in the <code>users</code> table.</p>
</li>
<li><p><code>SERIAL</code>: A PostgreSQL-specific data type for creating an auto-incrementing integer.</p>
</li>
<li><p><code>PRIMARY KEY</code>: This constraint specifies that the <code>id</code> column is the primary key for the table, meaning it uniquely identifies each row. Values in this column must be unique and not null.</p>
</li>
</ul>
</li>
<li><p><strong>email VARCHAR(255) UNIQUE NOT NULL</strong>:</p>
<ul>
<li><p><code>email</code>: The name of the second column, intended to store the user's username.</p>
</li>
<li><p><code>VARCHAR(50)</code>: A variable character string data type that can store up to 50 characters.</p>
</li>
<li><p><code>UNIQUE</code>: No two users can have the same username.</p>
</li>
<li><p><code>NOT NULL</code>: every row must have a username.</p>
</li>
</ul>
</li>
<li><h4 id="heading-reatedat-timestamp-with-time-zone-default-currenttimestamp"><strong>reated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP</strong></h4>
<ul>
<li><p><code>created_at</code>: The name of the fifth column.</p>
</li>
<li><p><code>TIMESTAMP WITH TIME ZONE</code>: This data type stores both a timestamp and a time zone.</p>
</li>
</ul>
</li>
</ol>
<p>Don't lose hope of learning Postgres this is just for the reading I know this is tough but you have to just read this and that's it. you don't have to learn this. I have a better and easier version for you. Which is PRISMA we will discuss this in PART-2 of this blog for now let's move ahead</p>
<p>💡</p>
<p>If you have access to a database right now, try running this command to create a simple table in there</p>
<ul>
<li>Then try running \dt; to see if the table has been created or not</li>
</ul>
<p>if you still don't understand let me explain to you briefly okay so:</p>
<h3 id="heading-step-1-install-docker">Step 1: Install Docker</h3>
<p>You have to install the docker locally by watching YouTube because this is the better way to use Postgres instead of using it online ok let's start after installing the docker locally your docker will look like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709729246503/43857d26-fd35-4f36-add0-e4930d2da81f.png" alt class="image--center mx-auto" /></p>
<p>after downloading you do not have to signin or signup you have to just start the docker using the terminal open the terminal and type</p>
<pre><code class="lang-plaintext">sudo systemctl start docker
</code></pre>
<p>after that, your docker gets started and you have to just open the terminal and run the command given below but before that, you can use whatever the password you want for your database in place of the mypassword <em>POSTGRES_PASSWORD=mysecretpassword</em></p>
<pre><code class="lang-plaintext">docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
</code></pre>
<p>after running this command you see something like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709729571647/e73f5db8-9f9e-4126-b83b-1004ba9dfeff.png" alt class="image--center mx-auto" /></p>
<p>you can see after running the command the instance of the postgres created in the docker now running. Now your connecting string is ready to use which is</p>
<pre><code class="lang-basic">postgresql://postgres:mysecretpassword@localhost:<span class="hljs-number">5432</span>/postgres?sslmode=disable
</code></pre>
<p>use your password instead of mypassword;</p>
<h3 id="heading-step-2-creating-the-user-table">Step 2: Creating the user table:</h3>
<p>open the new Terminal and run the <strong>docker ps</strong> command it will show you how many containers are there in the docker, now copy the containerID from it</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709729868283/2877546a-678e-4fcc-8de2-8c48e8bae519.png" alt class="image--center mx-auto" /></p>
<p>now we are going to open the terminal of the container for that we have to follow the command</p>
<pre><code class="lang-basic">docker exec -it CONTAINER ID psql -U postgres
</code></pre>
<p>write the container ID correctly now welcome to the Postgres terminal in the container which looks like</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709730105487/56be3f58-1142-4c58-831b-c77e6e6ba2d3.png" alt class="image--center mx-auto" /></p>
<p>now we have nothing in this so first we have to create the user table To create the user table we will follow these commands:</p>
<pre><code class="lang-basic">CREATE TABLE users (
    id SERIAL PRIMARY <span class="hljs-keyword">KEY</span>,
    username VARCHAR(<span class="hljs-number">50</span>) UNIQUE <span class="hljs-keyword">NOT</span> NULL,
    email VARCHAR(<span class="hljs-number">255</span>) UNIQUE <span class="hljs-keyword">NOT</span> NULL,
    password VARCHAR(<span class="hljs-number">255</span>) <span class="hljs-keyword">NOT</span> NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
</code></pre>
<p>I already explained this above so I have to proceed after running this command in your terminal the user table gets created like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709730284598/e1282f4f-32d3-407e-9213-31380d1a0fdb.png" alt class="image--center mx-auto" /></p>
<p>this is how you can create the user table in postgres. Now it is time to insert the user in it for that we have another command:</p>
<ul>
<li><strong>INSERT</strong></li>
</ul>
<pre><code class="lang-basic">INSERT INTO users (username, email, password)
VALUES (<span class="hljs-comment">'username_here', 'user@example.com', 'user_password');</span>
</code></pre>
<p>fill them according to your name email and password,</p>
<ul>
<li><strong>UPDATE</strong></li>
</ul>
<pre><code class="lang-basic">UPDATE users
SET password = <span class="hljs-comment">'new_password'</span>
WHERE email = <span class="hljs-comment">'user@example.com';</span>
</code></pre>
<ul>
<li><strong>DELETE</strong></li>
</ul>
<pre><code class="lang-basic"><span class="hljs-keyword">DELETE</span> FROM users
WHERE id = <span class="hljs-number">1</span>;
</code></pre>
<ul>
<li><strong>SELECT</strong></li>
</ul>
<pre><code class="lang-basic">SELECT * FROM users
WHERE id = <span class="hljs-number">1</span>;
</code></pre>
<p>To see the inserted user you have to use the command:</p>
<pre><code class="lang-basic">SELECT * FROM users;
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709730691256/e473bc47-914b-4768-8753-98691fa1cea6.png" alt class="image--center mx-auto" /></p>
<p>this is how easy it is.</p>
<h3 id="heading-what-about-the-nodejs-app-how-do-query-from-that">What about the Nodejs app how do Query from that?</h3>
<p><code>psql</code> is one such library that takes commands from your terminal and sends them over to the database.</p>
<p>To do the same in Node.js, you can use one of many <code>Postgres clients</code></p>
<p>but before that :</p>
<pre><code class="lang-basic">npm i pg
</code></pre>
<p>Connecting: -</p>
<pre><code class="lang-basic">import { Client } from <span class="hljs-comment">'pg'</span>

const client = <span class="hljs-keyword">new</span> Client({
  host: <span class="hljs-comment">'my.database-server.com',</span>
  port: <span class="hljs-number">5334</span>,
  database: <span class="hljs-comment">'database-name',</span>
  user: <span class="hljs-comment">'database-user',</span>
  password: <span class="hljs-comment">'secretpassword!!',</span>
})

client.connect()
</code></pre>
<p>Querying -</p>
<pre><code class="lang-basic">const result = await client.query(<span class="hljs-comment">'SELECT * FROM USERS;')</span>
console.<span class="hljs-keyword">log</span>(result)
</code></pre>
<p>this is a function to create a user table in your database.</p>
<pre><code class="lang-basic">import { Client } from <span class="hljs-comment">'pg'</span>

const client = <span class="hljs-keyword">new</span> Client({
  connectionString: <span class="hljs-string">"postgresql://postgres:mysecretpassword@localhost/postgres"</span>
})

async function createUsersTable() {
    await client.connect()
    const result = await client.query(`
        CREATE TABLE users (
            id SERIAL PRIMARY <span class="hljs-keyword">KEY</span>,
            username VARCHAR(<span class="hljs-number">50</span>) UNIQUE <span class="hljs-keyword">NOT</span> NULL,
            email VARCHAR(<span class="hljs-number">255</span>) UNIQUE <span class="hljs-keyword">NOT</span> NULL,
            password VARCHAR(<span class="hljs-number">255</span>) <span class="hljs-keyword">NOT</span> NULL,
            created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
        );
    `)
    console.<span class="hljs-keyword">log</span>(result)
}

createUsersTable();
</code></pre>
<p><strong><em>Sure! Looking forward to Part 2 of the Database Blog series with Prisma. If you have any more questions or need assistance in the future, feel free to reach out. Goodbye for now!</em></strong></p>
]]></content:encoded></item></channel></rss>