<?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 Rushikesh Mhetre on Medium]]></title>
        <description><![CDATA[Stories by Rushikesh Mhetre on Medium]]></description>
        <link>https://medium.com/@rushikesh-blogs?source=rss-e6e72d210b5d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aplNkzV3LdiOX3uQorXxow.jpeg</url>
            <title>Stories by Rushikesh Mhetre on Medium</title>
            <link>https://medium.com/@rushikesh-blogs?source=rss-e6e72d210b5d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 21:44:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rushikesh-blogs/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[The AI Plot Twist: We Asked for a Calculator… It Started Booking Meetings]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/the-ai-plot-twist-we-asked-for-a-calculator-it-started-booking-meetings-9096354485de?source=rss-e6e72d210b5d------2"><img src="https://cdn-images-1.medium.com/max/1536/1*VcpJ35loPd3xEyw-nO9pHA.png" width="1536"></a></p><p class="medium-feed-snippet">If you had told me three years ago that my biggest productivity boost wouldn&#x2019;t come from another JavaScript framework but from arguing&#x2026;</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/the-ai-plot-twist-we-asked-for-a-calculator-it-started-booking-meetings-9096354485de?source=rss-e6e72d210b5d------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/the-ai-plot-twist-we-asked-for-a-calculator-it-started-booking-meetings-9096354485de?source=rss-e6e72d210b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9096354485de</guid>
            <category><![CDATA[short-story]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[funny]]></category>
            <category><![CDATA[positive-thinking]]></category>
            <dc:creator><![CDATA[Rushikesh Mhetre]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 14:05:53 GMT</pubDate>
            <atom:updated>2026-11-05T14:49:17.980Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Create Twitter Bot using NodeJs and Deploy on Heroku]]></title>
            <link>https://rushikesh-blogs.medium.com/create-twitter-bot-using-nodejs-and-deploy-on-heroku-dd6ec31534f4?source=rss-e6e72d210b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd6ec31534f4</guid>
            <category><![CDATA[twitterbots]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Rushikesh Mhetre]]></dc:creator>
            <pubDate>Sun, 23 May 2021 08:41:40 GMT</pubDate>
            <atom:updated>2021-05-26T00:35:17.841Z</atom:updated>
            <content:encoded><![CDATA[<p>Twitter! We all know what Twitter is and most of us are familiar with its “microblogging” feature. We use the features like status posting, retweeting, liking, commenting and so on.</p><p><strong><em>This article is to learn how to automate these features using a twitter bot</em></strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1lxryzbQaqo49cKhCw%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F1lxryzbQaqo49cKhCw%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F1lxryzbQaqo49cKhCw%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/97c7c0535da139a618dd9e483a1a6f37/href">https://medium.com/media/97c7c0535da139a618dd9e483a1a6f37/href</a></iframe><blockquote>There are many things you can do with your bot, they are only limited to our own imagination.</blockquote><h3>We are going to create a twitter bot which will do two things</h3><ol><li>Post a joke on a daily basis.</li><li>Follow certain hastags, <strong><em>like</em></strong> the tweets containing those hashtags and <strong><em>retweet</em></strong> them.</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FiJzfxhZyGuCmYdY3jf%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FiJzfxhZyGuCmYdY3jf%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FiJzfxhZyGuCmYdY3jf%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/29d5c610f6efa693ef89b1c7edda8c18/href">https://medium.com/media/29d5c610f6efa693ef89b1c7edda8c18/href</a></iframe><h3>Step 1: Apply for Twitter Developer Account</h3><p>Duh! Of course we will need a developer account. How else are we going to create the bot? 😅</p><ul><li>Login into <a href="https://twitter.com/">Twitter</a></li><li>Go to <a href="https://developer.twitter.com/en/apply-for-access">developers.twitter.com</a> and click on ‘Apply for a Developer account’</li><li>Select the type of application i.e. student/business/hobbyist, etc. Choose student or hobbyist. ( It doesn’t really matter unless its a business account. There are different rules for the business account )</li><li>Mention the purpose of your application. Try to be specific w.r.t what you are going to do with your Bot, in my case I added “I am going to post random jokes daily. Follow some hashtags, like &amp; retweet them”. <br>The more specific you are, the better are your chances of getting the approval.</li></ul><h3>Important! Read all the guidelines before applying</h3><blockquote>Make sure you have read the <a href="https://developer.twitter.com/en/developer-terms/agreement-and-policy">Developer Agreement and Policy</a>, <a href="https://help.twitter.com/en/rules-and-policies/twitter-automation">Automation Rules</a> and <a href="https://help.twitter.com/en/rules-and-policies/twitter-rules">The Twitter Rules</a> before applying</blockquote><h4>We are getting there….</h4><h3>Step 2: Create your app on Twitter</h3><p>Create your app after your developer account has been approved. Now a days, it doesn’t really take much time.</p><ul><li>Follow this <a href="https://developer.twitter.com/en/portal/apps/new">create app url</a>. Fill in the required details.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LewiNgSPsOMAF29erZgzcA.png" /></figure><ul><li>Hit next after you enter your app name. This will show you your keys &amp; tokens.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oigP8y3sUYOuo_ZN54SOlw.png" /><figcaption>Don’t waste your time copying my creds, I have already deleted those 🤞🏽</figcaption></figure><ul><li>Now go to <strong>App Permissions </strong>and hit Edit, select <strong>Read and Write</strong> option from the options, as we want our app to be able to Read and Write.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*eFNUEXC8MZ198TYoILUV1A.png" /></figure><ul><li>Hitting Save button will ask your for confirmation, say “Yes”.</li><li>Now, on the <strong>Overview, </strong>select your App and you will see a key 🔑 icon next to the app name. Go ahead and click it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*w3ByVzo7wAHHDjyZg3lEzQ.png" /></figure><ul><li>You should now see your <strong>Consumer keys</strong> and <strong>Authentication Tokens</strong></li><li>Generate The <strong>Access Token and Secret</strong>, store them somewhere secured as we will be needing them for the our operations.</li></ul><h4>Almost there…</h4><h3>Step 3: Setting up the development environment</h3><p>Make sure you have NodeJs, npm installed on your machine</p><p>For Ubuntu, install using the following commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CW1zO8cpaaLFfwRNnyiUaQ.png" /></figure><p>For Mac or Windows, click <a href="https://nodejs.org/en/">here</a> for the installation instructions</p><p>Create a directory named &lt;your-bot-name&gt;<br>In my case, I have named lazy-twitter-bot</p><p>We are going to use <a href="https://www.npmjs.com/package/twit">twit</a> npm package. Its a Twitter API client for NodeJs. <br>Enter the below commands inside the &lt;your-bot-name&gt; directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*XAIVYgF2yjLBbFRPK36VkA.jpeg" /></figure><p>Your Node.js dev environment setup is now complete 🎉</p><h3>Step 4: Development the bot</h3><p>Before we start with the development, we need to authenticate twit . To do this, we will be using our API keys, Access Token, etc we saved in the earlier steps.</p><ul><li>Create folder name config in your root.</li><li>Add a file name config.env and enter the follow code in it.</li></ul><p><strong>config.env</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c5hO_WJHz5DLjIzVqYFNSg.png" /></figure><ul><li>Add this file in your .gitignore file as we don’t the secrets to be pushed to our git repo.</li><li>Install <a href="https://www.npmjs.com/package/dotenv">dotenv</a> npm package, this will help us load the environment vairables.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*KNE2N6yvjxRKZ4mfCI39CQ.png" /></figure><ul><li>Add <a href="https://www.npmjs.com/package/axios">axios</a> npm package. We will be using this to fetch the joke and post it using our bot.</li></ul><p>Now that we have added our .env file, installed our dependencies, let’s go ahead and create index.js which will be our entry point to our bot.</p><blockquote>In my case, I am using index.js to write my bot code. You can name it anything you want based on your idea. I will be writing all code in file as this code is just for the demo purposes. I think each feature should have its dedicated .js file provided you’re building multiple features</blockquote><p>Below is the code for our bot</p><p><strong>index.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a565231cee5a7547ed03dc661c2ab925/href">https://medium.com/media/a565231cee5a7547ed03dc661c2ab925/href</a></iframe><p>Let’s understand the code</p><ul><li>Import our config from ./config folder</li><li>Import Twit from twit package</li><li>Import axios from axios package</li><li>Initialize the <strong>T instance using</strong>Twit with the config we imported from config.env</li><li><strong>postStatusUpdate method</strong></li></ul><ol><li>This function will basically run every day ( 86400000 being in ms ), we have done this with a simple setInterval API.</li><li>Do a GET call to <a href="https://icanhazdadjoke.com/">this</a> website. This is pretty cool website which I found which generates jokes. It has multiple params by which you can fetch the joke. I have done a simple call which returns a single joke on a random basis.</li><li>Once we have the joke object we post it using <br><strong>T.post(‘statuses/tweet’, { status: joke }, responseCallback );</strong></li><li>responseCallback is our common method to handle the response of the Twitter APIs.</li><li>Run node index.js</li><li>This will post our tweet! 🎉🎉 This is so simple isn’t it? To verify please login to twitter and check if the tweet has been posted</li></ol><ul><li><strong>LikeAndRetweet method</strong></li></ul><ol><li>This function will run every hour, follow these hastags <br>`#JavaScript, #nodejs, #mongoDB, #vuejs, #reactjs, #expressjs`</li><li>We will be creating a stream which will observe/scan tweets containing these hashtags.</li><li>With on tweet event, we get the tweet object. We then use favorite/create property to like the tweet and statuses/retweet/:id to retweet the update.</li><li>Now again run the file using node index.js</li><li>You should now see multiple tweets being liked and retweeted 🎉</li></ol><p>To understand more about the APIs, properties please visit <a href="https://github.com/ttezel/twit"><strong>this</strong></a><strong>.</strong></p><h3>Step 5: Deploy the bot on Heroku</h3><ul><li>Create an account on <a href="https://id.heroku.com/login">Heroku</a></li><li>Create and app with &lt;your-bot-name&gt; on Heroku</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*KnEzHV6UFIT93HIKBwZk2w.png" /></figure><ul><li>This will open up a form, enter the required details. The app name should be the name of your local project directory</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJXqwfKzRryO6XlgxoJS7A.png" /></figure><ul><li>Now install <strong>heroku-cli </strong>on your machine using the below command</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*LJK_WHe_01RpgdbAhUUTJw.png" /></figure><ul><li>For windows, Linux or other installation methods please follow <a href="https://devcenter.heroku.com/articles/heroku-cli">this</a> link.</li><li>For heroku to understand our bot start command, we create a <strong>Procfile </strong>having the below code</li><li><strong>Procfile</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*Hm4vcYqMM_bUnZVdSzPppg.png" /></figure><ul><li>Let’s login to heroku using below CLI command</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*AYNkHvk65G-8Q1eUBhIM-A.png" /></figure><ul><li>This will open a login link in your browser, enter your password. After successful login you can now close the tab.</li><li>Deploy the bot on Heroku using these commands</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCZqvtpcxBT_RtkJ5bDV9Q.png" /></figure><h4>We are almost there..</h4><p>Now that our bot is deployed on Heroku, we need to start it so that it do the job we have coded it for.</p><p>Start the <em>worker</em> on Heroku</p><ul><li>Go to <a href="https://dashboard.heroku.com/apps">https://dashboard.heroku.com/apps</a> and click your bot app</li><li>Then click on the <strong>configure Dynos</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*f-KVujzsaJ4c-wjj9HGc4w.png" /></figure><ul><li>Switch off the web npm start<strong> </strong>and start the<strong> </strong>worker node index.js and confirm</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGAhlzY_M6JvjgUYfvJyGQ.png" /></figure><h3>And the bot is Ready! 🍾🎊</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fyx5CGBdwXdCbjEf6li%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fyx5CGBdwXdCbjEf6li%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fyx5CGBdwXdCbjEf6li%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a35b0d0825e6d5b0b3d47b595d7ca47/href">https://medium.com/media/9a35b0d0825e6d5b0b3d47b595d7ca47/href</a></iframe><h3>The randomBot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjIUeQVyhbR0Jdk4hlN_6A.png" /></figure><p>You can you follow this <a href="https://twitter.com/randomB57847791"><strong>link</strong></a> see the bot in work</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3xnw0Dghl2BbnnswLB-wmQ.png" /></figure><h3>Source Code for the Bot</h3><p><a href="https://github.com/Nomercy10/lazy-twitter-bot">Nomercy10/lazy-twitter-bot</a></p><h3>And we are done!</h3><p>Feedback is always appreciated!</p><p>Thank you for reading! 🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd6ec31534f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a microservice with NodeJs, Express and MongoDB]]></title>
            <link>https://rushikesh-blogs.medium.com/how-to-build-a-microservice-with-nodejs-express-and-mongodb-73737b6fa868?source=rss-e6e72d210b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/73737b6fa868</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Rushikesh Mhetre]]></dc:creator>
            <pubDate>Wed, 12 May 2021 11:13:04 GMT</pubDate>
            <atom:updated>2021-05-17T00:30:16.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qkxnndNb1ETR0V_78L2Pwg.png" /></figure><p>Most of us have gone through tough times where you have a large scale application which has a bunch of features, API integrations, database connections, etc. New features and updates get released, and of course you need to fix the bugs and maintain the code.</p><p>Building this real-world application requires dynamic programming, where the size of the application grows uncontrollably.</p><p>This monolith pattern becomes very hard to downsize or simplify the application. So to run the app smoothly, it is essential to convert the large, homogeneous structure into small, independent pieces of programs. Similar complexities can be resolved effortlessly when the NodeJs applications are build on <strong>microservices, </strong>more so with the Node.js ecosystem.</p><p>So I am going to show you how to build the microservices…</p><blockquote>This blog is only for an overview of how to build the services, please visit <a href="https://github.com/Nomercy10/ecommerce-micro-services">https://github.com/Nomercy10/ecommerce-micro-services</a> for a full functional working microservices demo.</blockquote><p>In our example we will be building two microservices, <strong><em>Users &amp; Orders. </em></strong>The idea is very simple, users will place an order. We create the order with all the required details, and so on.</p><p>Here is the list of the features each of these microservice will have</p><h4>Users</h4><ul><li>GET all users</li><li>GET user</li><li>Create new user</li><li>DEL user by userId</li></ul><h4>Orders</h4><ul><li>GET all orders</li><li>GET order</li><li>GET orders for a user</li><li>Create new order for a user</li><li>DEL an order</li><li>DEL orders for an user</li></ul><h3>Tech</h3><ul><li><a href="https://nodejs.org/">Node.js</a> : evented I/O for the backend</li><li><a href="http://expressjs.com/">Express</a> : Fast node.js network app framework</li><li><a href="https://www.mongodb.com/">MongoDb</a> : A NoSql database for modern applications</li></ul><p>As we build these microservices we will create separate folders for each microservice. Each folder will have its own package.json and node modules installed.</p><p>Let’s get started…</p><h3>Installation</h3><p>Create Users folder and install below dependencies</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*wDmPGwtWmkeDf41LCZve3w.png" /><figcaption>Users installed dependencies</figcaption></figure><p>Info about the dependencies</p><ul><li><strong><em>body-parser</em></strong><em>:</em> <em>It is a Node.js body parsing middleware, it parses incoming request bodies in a middleware before your handlers and is available under </em>req.body<em> property.</em></li><li><strong><em>axios</em></strong><em>: A promise based HTTP client for browser and Node Js.</em></li><li><strong><em>nodemon</em></strong><em>: A tool used for Node Js development as it provides hot-reloading for any file change.</em></li><li><strong><em>mongoose</em></strong><em>: A MongoDB Object modelling tool designed to work in an asynchronous environment.</em></li></ul><h3>Development</h3><p>Create Users.jsin the /Users folder, this file will be our entry point to Users microservice.</p><p>Load the dependencies</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*puf0ITJf2bHxqzOVesgmmA.png" /><figcaption>Load dependencies</figcaption></figure><h3>Install the MongoDB Node.js Driver</h3><p>The MongoDB Node.js Driver allows you to easily interact with MongoDB databases from within Node.js applications. You’ll need the driver in order to connect to your database and execute the queries described in this Quick Start series.</p><p>If you don’t have the MongoDB Node.js Driver installed, you can install it with the following command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*hfUl7T8uYc-p60FK_D4LBw.png" /></figure><h3>Create a free MongoDB Atlas cluster and load the sample data</h3><p>Next, you’ll need a MongoDB database. The easiest way to get started with MongoDB is to use Atlas, MongoDB’s fully-managed database-as-a-service.</p><p><a href="https://www.mongodb.com/cloud/atlas">Head over to Atlas</a> and create a new cluster in the free tier. At a high level, a cluster is a set of nodes where copies of your database will be stored. Once your tier is created, <a href="https://docs.atlas.mongodb.com/sample-data/">load the sample data</a>.</p><h3>Get your cluster’s connection info</h3><p>The final step is to prep your cluster for connection.</p><p>In <a href="https://www.mongodb.com/cloud/atlas">Atlas</a>, navigate to your cluster and click <strong>CONNECT</strong>. The Cluster Connection Wizard will appear.</p><p>The Wizard will prompt you to add your current IP address to the IP Access List and create a MongoDB user if you haven’t already done so. Be sure to note the username and password you use for the new MongoDB user as you’ll need them in a later step.</p><p>Next, the Wizard will prompt you to choose a connection method. Select Connect Your Application. When the Wizard prompts you to select your driver version, select Node.js and 3.6 or later. Copy the provided connection string as you will use in the following section.</p><p>For more details on how to access the Connection Wizard and complete the steps described above, see the <a href="https://docs.atlas.mongodb.com/connect-to-cluster/">official documentation</a>.</p><h3>Connect to your database from a Node.js application</h3><p>Now that everything is set up, it’s time to code! Let’s write a Node.js script that connects to your database and lists the databases in your cluster.</p><h3>Import mongoose client</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Elg2AMZsZ-n6-oNEgtNt7w.png" /></figure><p>The mongoose client will be used to connect to a MongoDB database. This is an instance of MongoDb to connect to a cluster, access the database in that cluster, and close the connection to that cluster.</p><p>The first thing after this we need to do is create a constant for our connection URI. The connection URI is the connection string you copied in Atlas in the previous section. When you paste the string don’t forget to update &lt;username&gt; and &lt;password&gt; to be the credentials for the user you created in the previous section. The connection string includes a &lt;dbname&gt; placeholder.</p><p><strong>Note: </strong>The username and password you provide in the connection string are NOT the same as your Atlas credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ImrgGjVZcODWYaOE7n-bhw.png" /><figcaption>Connection string URI</figcaption></figure><p>Now that we have the URI, we can create an instance of the MongoDB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZB_wZDkkyOEyv_eqbO3BA.png" /><figcaption>inItialization of MongoDB client and loading the global instance</figcaption></figure><h3>Database Models</h3><p>Now that we have our connection setup, let’s go ahead and create MongoDB data models. We will be using mongoose.model <br><a href="https://mongoosejs.com/docs/api.html#model-js">Models</a> are fancy constructors compiled from Schema definitions. An instance of a model is called a <a href="https://mongoosejs.com/docs/documents.html">document</a>. Models are responsible for creating and reading documents from the underlying MongoDB database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtBSq2cMu-8kkHN8XF9Ctg.png" /></figure><h3>APIs</h3><p>For the sake of this blog not becoming too long to read I am going to show only two APIs. You may create the others I referenced or as many features you want.</p><p><em>GET all orders for a user API</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMAaGOPyy65eRaRt2Sw96Q.png" /></figure><p>As you can see above, when we trigger “/users/:uid/” orders we are making an external API call to Orders microservice and a call the GET API for “/orders?uid= ”. This way we have communicated between the microservices and have shared data.</p><p><em>Create new user API</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DlrhSBuY6nQTuHVhs9t6DQ.png" /></figure><p>In the above example, we are creating a new user. First we create a newUser object with the response from the request body.<br>We then create a new “User” instance, a MongoDB data model User instance &amp; pass the “newUser” to it.</p><p>We can now use .save() property to save the data to MongoDB. As its a promise based property we can use .then and perform the operation we want to.</p><p><strong>Note: </strong>Note: I am not showing here how to create the microservice for Orders as it is pretty straightforward and similar to what we have done for Users microservice. If you still need to see how to implement that, please visit my github repo link mentioned above at the start of the blog.</p><blockquote>PS: This is my first technical blog, please leave comments if you feel I should add something I am missing or a clap if you like it.</blockquote><p>Thankyou!</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73737b6fa868" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>