<?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 Vamsi Krishna Karanam on Medium]]></title>
        <description><![CDATA[Stories by Vamsi Krishna Karanam on Medium]]></description>
        <link>https://medium.com/@kvamsi1026?source=rss-a07e5d735a3c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FLdbx9fiz2aH7y_nYcD13w.jpeg</url>
            <title>Stories by Vamsi Krishna Karanam on Medium</title>
            <link>https://medium.com/@kvamsi1026?source=rss-a07e5d735a3c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:55:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kvamsi1026/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[Mongoose = Mongo with ease]]></title>
            <link>https://medium.com/@kvamsi1026/mongoose-mongo-with-ease-10bb63688b59?source=rss-a07e5d735a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/10bb63688b59</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[mongoosejs]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Vamsi Krishna Karanam]]></dc:creator>
            <pubDate>Fri, 29 May 2020 16:00:05 GMT</pubDate>
            <atom:updated>2020-05-29T16:00:05.510Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*8w2sRdiOVgk5S4uaSWWuKw.png" /></figure><p>In the <a href="https://medium.com/@kvamsi1026/using-mongo-db-with-node-js-ca95040f7c7b">last article</a>, I shared about using Mongo DB with Nodejs. If you haven’t read it yet, I recommend you have a look at it before proceeding with the current article, as we are gonna discuss a lot about it here.</p><p>In this tutorial, we are gonna use a simple Nodejs package called Mongoose, which will eliminate the need to write a lot of boilerplate code as we did in the last tutorial, thereby making it much faster and efficient to use Mongo DB in our projects. As it says in their <a href="https://mongoosejs.com/">official website</a> “Let’s face it, <strong>writing MongoDB validation, casting and business logic boilerplate is a drag</strong>. That’s why we wrote Mongoose”. This pretty much sums it up the point of using this one of the most useful packages in Nodejs. Without further ado let’s see it in action.</p><p>So as usual to use a package in Nodejs we have to first <em>install </em>and <em>require </em>it in our <em>index.js</em> file.</p><pre>&gt; npm install mongoose</pre><p>Let’s require it in our index file :</p><pre>const mongoose = require(&#39;mongoose&#39;);</pre><p>Now let’s connect to our database</p><pre>mongoose.connect(&#39;mongodb://localhost:27017/test&#39;, {useNewUrlParser: true, useUnifiedTopology: true});</pre><p>That’s it! This one line of code does all of creating a new collection and connecting it using the MongoDB port at the localhost. If we take a look at our previous version of the same code where we used the raw Mongo package we can clearly see the difference.</p><pre>//connecting to Mongo DB using mongo<br>var MongoClient = require(&#39;mongodb&#39;).MongoClient;<br>var url = &quot;mongodb://localhost:27017/mydb&quot;;</pre><pre>MongoClient.connect(url, function(err, db) {<br>  if (err) throw err;<br>  console.log(&quot;Database created!&quot;);<br>  dbo.createCollection(&quot;customers&quot;, function(err, res) {<br>    if (err) throw err;<br>    console.log(&quot;Collection created!&quot;);<br>    db.close();<br>  });<br>  db.close();<br>});</pre><pre>//connecting to Mongo DB using mongoose<br>const mongoose = require(&#39;mongoose&#39;); mongoose.connect(&#39;mongodb://localhost:27017/newCustomers&#39;, {useNewUrlParser: true, useUnifiedTopology: true});</pre><p>Feeling relieved? Yeah, me too. Now let’s understand the code here. First-line shows we are requiring mongoose in our file. In the next line, we specify the location of our new database collection.</p><pre>mongodb://localhost:27017/<strong>newCustomers</strong></pre><p>There is no need of creating a separate collection. We can directly specify a new name in the connection URL itself. Then the next two arguments <em>useNewUrlParser </em>and <em>useUnifiedTopology </em>are there to avoid Mongoose deprecation warnings. If you’re curious you can read more about them in the <a href="https://mongoosejs.com/docs/deprecations.html">mongoose docs</a>.</p><p>After connecting to the database we need to create a schema of our collection. Now, a schema is nothing but a JSON object, which acts as a blueprint to our MongoDB collection. You’ll get a better idea when you look at the code.</p><pre>const customerSchema = {<br>   name: String,<br>   age: Number,<br>   address: String<br>};</pre><p>It’s that simple. In some cases, you may also see the same schema created as follows :</p><pre>const customerSchema = mongoose.schema({<br>   name: String,<br>   age: Number,<br>   address: String<br>});</pre><p>Both of these are valid, but the latter specifies it as a mongoose schema which will be needed in cases such as data encryption. You can use either of them unless you’re encrypting the data. Now in order to perform CRUD operations on the data, we have to use this schema to create a mongoose model. Think of this model as a building provided with a blueprint called schema. This might be confusing at first, but you’ll get used to it by practice.</p><pre>const Customer = new mongoose.model(&quot;Customer&quot;, customerSchema);</pre><p>It’s time to write into our database. To do that let’s create a record that is to be inserted.</p><pre>var firstCustomer = new Customer({<br>   name: &quot;Vamsi&quot;,<br>   age: &quot;21&quot;,<br>   address: &quot;28, Balaji Nagar&quot;<br>});</pre><pre>firstCustomer.save();</pre><p>Yay! We have inserted our first record into our <em>newCustomers </em>collection. Pat on the back. To verify whether it has been inserted or not, open the Mongo shell by following the same steps from the last tutorial and use <em>db.newCustomers.find()</em> query. If it returns a new record, congratulations! If not make sure you have corrected all the errors. Moving on, let’s see how can we read/retrieve a record from our collection.</p><pre>Customer.findOne({name: &quot;Vamsi&quot;}, function(err, foundCustomer){<br>   if(!err) console.log(foundCustomer.address);<br>   else console.log(err);<br>});</pre><p>This <em>findOne() </em>method will return the found record matching with the given argument name, and if no record exists with such a name it returns an error. Additionally, you can also use other methods like <em>findOneById(), find() </em>etc. To update one record in our collection we will use findOneAndUpdate() as follows :</p><pre>Customer.findOneAndUpdate(_id: id, {$set: {address: &quot;Door No. 28, Balaji Nagar&quot;}}, function(err){<br>   if(!err) console.log(&quot;Updated successfully!&quot;);<br>   else console.log(err);<br>});</pre><p>Here the <em>id </em>is the default id assigned by Mongo DB to our record which can be found in the Mongo shell. The update can also be done by passing other options like name for our model. Now the last and final part deleting a record. To delete a single record we use the <em>findOneAndRemove()</em> method.</p><pre>Customer.findOneAndRemove(_id: id, function(err){<br>   if(!err) console.log(&quot;Deleted successfully!&quot;);<br>   else console.log(err);<br>});</pre><p>There are several other functions in mongoose to perform these same four operations. Check out their <a href="https://mongoosejs.com/docs/">documentation</a> if you want to know more. But I’m gonna stop with this for my three-part Mongo DB tutorial. If you have followed all the steps discussed in these three articles, thanks a lot for taking some time to do so. Feel free to comment your thoughts/suggestions. Share these articles if you think someone may find them useful. Until next time, thank you and have a good day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10bb63688b59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Mongo DB with Node JS]]></title>
            <link>https://medium.com/@kvamsi1026/using-mongo-db-with-node-js-ca95040f7c7b?source=rss-a07e5d735a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca95040f7c7b</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Vamsi Krishna Karanam]]></dc:creator>
            <pubDate>Mon, 25 May 2020 06:41:11 GMT</pubDate>
            <atom:updated>2020-05-25T06:41:11.431Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://medium.com/@kvamsi1026/mongo-db-the-savior-of-backend-c63d1e7193cf">last article</a>, I talked about Mongo DB installation, and how to use it within the Mongo shell. If you haven’t read it yet, I strongly recommend you go through it and then come back here. Assuming that you have everything set up as mentioned in the last article, now I’m gonna talk about how Mongo DB when combined with any web framework like Node.js, will become a very powerful backend system. So without further ado let’s jump into it.</p><p><a href="https://nodejs.org/en/">Node.js</a> is a free, open-source Javascript runtime built on <a href="https://v8.dev/">Chrome’s V8 Javascript engine</a>. It is basically used as a server environment and also supports various browsers. It is one of the most used Javascript runtimes in the developer community.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*zsLizK5G6I0ISv2bUSDuMg.png" /></figure><p>These are the most wanted web frameworks according to the <a href="https://insights.stackoverflow.com/survey/2019#most-loved-dreaded-and-wanted">survey done by StackOverflow</a>. This shows how web developers love to work with the Node.js framework. With that said, we can now start our tutorial on how Mongo DB can be combined with Node.js in backend development.</p><p>In order to use Node JS we have to first install it. You can download install Node from their official <a href="http://nodejs.org/">website</a>. Once you’re done check if the installation is successful by opening a new command prompt and giving the command :</p><pre>node --version</pre><p>If it returns the version of Node that you’ve installed, you’re good to go. If not try setting the environment variables for Node <a href="https://stackoverflow.com/questions/13593902/node-command-not-found">manually</a>. With Node installed it should have also installed NPM (Node package manager) with it. Verify this by giving the command :</p><pre>npm --version</pre><p>If it returns the version, it means we have successfully installed Node and NPM (even if the version is different from that of the node). By using NPM we can install various node projects. For this tutorial, we are gonna use <a href="http://expressjs.com/">Express</a> (to set up the local server), Mongo packages.</p><p>First, create a directory to hold all our project files in your preferred location. Now cd over to that directory. Here is where we are gonna initialize our first Node.js project. To do so, give the command :</p><pre>npm init</pre><p>which will return the following :</p><pre>This utility will walk you through creating a package.json file.<br>It only covers the most common items, and tries to guess sensible defaults.</pre><pre>See `npm help init` for definitive documentation on these fields<br>and exactly what they do.</pre><pre>Use `npm install &lt;pkg&gt;` afterwards to install a package and<br>save it as a dependency in the package.json file.</pre><pre>Press ^C at any time to quit.<br>package name: (&lt;yourFolderName&gt;)</pre><p>Give the desired name for your project, or just hit enter to set the name to folder name. Do the same for version, description, entry point, test command, git repository, keywords, author, and license. You will then arrive at :</p><pre>About to write to C:\Users\User1\Desktop\MyFirstNodeProject\package.json:</pre><pre>{<br>  &quot;name&quot;: &quot;article&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;<br>  },<br>  &quot;author&quot;: &quot;&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;<br>}</pre><pre>Is this OK? (yes)</pre><p>Hit enter. Now you will have a package.json file created in the same directory. Open this project folder in a code editor of your choice (<a href="https://code.visualstudio.com/">Visual Studio Code</a>/ <a href="https://atom.io/">Atom </a>etc.) If you don’t have any it’s not a problem. You can also edit your files in notepad. But I strongly recommend you download one of the code editors mentioned above, as they will be very helpful in organizing and writing code. In the editor create a new file named index.js at the same level. Now it’s time to install our node packages. Open the command prompt and issue the following command :</p><pre>npm i express mongodb</pre><p>which even though takes some time, installs those two packages and returns the confirmation message which looks something like this, depending on the version installed in your machine:</p><pre>npm notice created a lockfile as package-lock.json. You should commit this file.<br>npm WARN article@1.0.0 No repository field.</pre><pre>+ mongodb@3.5.7<br>+ express@4.17.1<br>added 66 packages from 45 contributors and audited 66 packages in 37.443s<br>found 0 vulnerabilities</pre><p>Now open the index.js file in your code editor. First we are gonna set the server up and running using express. To do this write the following code into index.js file.</p><pre>const express = require(&quot;express&quot;);<br>const app = express();</pre><pre>app.listen(3000, function(){<br>  console.log(&quot;Server has been started on port 3000&quot;);<br>});</pre><p>To check if the code is running as it is intended to, open the command prompt and run it using :</p><pre>node index.js</pre><p>It should say “Server has been started on port 3000”. Congratulations! You have successfully set up your own local server. Now to give some response to the user, let’s create a get method above our listen method in index.js file as follows :</p><pre>app.get(&quot;/&quot;, function(req, res){<br>  res.send(&quot;&lt;h1&gt;Hello world&lt;/h1&gt;&quot;);<br>});</pre><p>This will render the text “Hello world” into the response file. To have a better understanding run the file again and open any browser of your choice. Type the URL <em>localhost://3000. </em>You can now be able to see Hello world in large bold letters. Now let’s see how we can connect to MongoDB and send that data as a response to the browser. Create a variable that requires the installed mongodb package as :</p><pre>const mongodb = require(&quot;mongodb&quot;);</pre><p>Now to create a new database, we have to create a new MongoClient and a local URL for the MongoDB collection, and finally, a new collection to store the data, which is exactly done by the following code :</p><pre>var MongoClient = require(&#39;mongodb&#39;).MongoClient;<br>var url = &quot;mongodb://localhost:27017/mydb&quot;;<br><br>MongoClient.connect(url, function(err, db) {<br>  if (err) throw err;<br>  console.log(&quot;Database created!&quot;);<br>  dbo.createCollection(&quot;customers&quot;, function(err, res) {<br>    if (err) throw err;<br>    console.log(&quot;Collection created!&quot;);<br>    db.close();<br>  });<br>  db.close();<br>});</pre><p>Now let’s insert one document into our customers collection. In order to do this, we have to create a new JSON object and call the <em>insertOne()</em> function on the customers collection as follows :</p><pre>  var myobj = { name: &quot;Vamsi&quot;, address: &quot;Highway 37&quot; };<br>  dbo.collection(&quot;customers&quot;).insertOne(myobj, function(err, res) {<br>    if (err) throw err;<br>    console.log(&quot;1 document inserted&quot;);<br>    db.close();<br>  });</pre><p>Now let us retrieve this data to show in our response. For this we are using the <em>findOne()</em> method on customers collection.</p><pre>dbo.collection(&quot;customers&quot;).findOne({}, function(err, result) {<br>    if (err) throw err;<br>    var CustomerName = result.name;<br>    db.close();<br>  });</pre><p>Now let’s change our response in <em>app.get()</em> method so that it will display the customer name as a response to the get call.</p><pre>app.get(&quot;/&quot;, function(req, res){<br>  res.send(&quot;&lt;h1&gt;Welcome &lt;h1&gt;&quot;+customerName);<br>});</pre><p>Now if you go ahead and run the <em>index.js</em> file and open the <em>localhost://3000</em> you will see the message saying “<strong>Welcome Vamsi” </strong>or whichever name you have given in the <em>insertOne()</em> method. The final code looks like this :</p><pre>const express = require(&quot;express&quot;);<br>const app = express();<br>const mongo = require(&quot;mongodb&quot;);</pre><pre>var MongoClient = require(&#39;mongodb&#39;).MongoClient;<br>var url = &quot;mongodb://localhost:27017/mydb&quot;;</pre><pre>MongoClient.connect(url, function(err, dbo) {<br>  if (err) throw err;<br>  console.log(&quot;Database created!&quot;);<br>  dbo.createCollection(&quot;customers&quot;, function(err, res) {<br>    if (err) throw err;<br>    console.log(&quot;Collection created!&quot;);<br>    db.close();<br>  });</pre><pre>var myobj = { name: &quot;Vamsi&quot;, address: &quot;Highway 37&quot; };<br>  dbo.collection(&quot;customers&quot;).insertOne(myobj, function(err, res) {<br>    if (err) throw err;<br>    console.log(&quot;1 document inserted&quot;);<br>    db.close();<br>  });</pre><pre>dbo.collection(&quot;customers&quot;).findOne({}, function(err, result) {<br>    if (err) throw err;<br>    var CustomerName = result.name;<br>    db.close();<br>  });</pre><pre>dbo.close();<br>});</pre><pre>app.get(&quot;/&quot;, function(req, res){<br>  res.send(&quot;&lt;h1&gt;Welcome &lt;h1&gt;&quot;+customerName);<br>});</pre><pre>app.listen(3000, function(){<br>  console.log(&quot;Server has been started on port 3000&quot;);<br>});</pre><p>That’s all for this tutorial. If you have reached here following all the steps, thank you for spending your time on my article. Feel free to comment your thoughts/questions/suggestions. In the next article, we will see how we can refractor and reduce the amount of code we wrote here just by using a simple node.js package which will take most of the weight for us. See you there!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca95040f7c7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mongo DB — The savior of backend]]></title>
            <link>https://medium.com/@kvamsi1026/mongo-db-the-savior-of-backend-c63d1e7193cf?source=rss-a07e5d735a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c63d1e7193cf</guid>
            <dc:creator><![CDATA[Vamsi Krishna Karanam]]></dc:creator>
            <pubDate>Fri, 22 May 2020 15:51:53 GMT</pubDate>
            <atom:updated>2020-05-25T07:01:42.867Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*R59zX2kDfkx_RFe4ut53mw.png" /></figure><h3>Mongo DB — The savior of backend</h3><p>Being a web/app developer, it’s of utmost importance for one to learn not only about designing the eye-catching, colorful user interfaces (front-end) but also equally or in some cases more importantly the backend technologies. And I’m sure that most of you might have come across SQL, MySQL, NoSQL, PostgreSQL (include everything SQL for that matter) with bold-lettered syntax, involving complex queries just to get a simple task done, as far as a full-stack development is concerned. If you’re like me, you are well versed and got used to the traditional programming syntax to a level where you might find understanding the DDL and DML challenging. This is where <strong>Mongo DB</strong> comes into the picture. Mongo DB, as it says in their official <a href="https://www.mongodb.com/">website</a>, is a “<em>document-based, general-purpose, distributed database </em>built for modern application developers”. You might have already noticed why it is special.</p><p>Mongo DB is a document-based database, meaning it stores data in JSON format as shown below.</p><pre>{   <br>   &quot;_id&quot;: &quot;5cf0029caff5056591b0ce7d&quot;,   <br>   &quot;firstname&quot;: &quot;Vamsi Krishna&quot;,   <br>   &quot;lastname&quot;: &quot;Karanam&quot;,<br>   &quot;address&quot;: {     <br>      &quot;street&quot;: &quot;Balaji Nagar&quot;,     <br>      &quot;city&quot;: &quot;Tirumala&quot;,     <br>      &quot;state&quot;: &quot;AP&quot;,     <br>      &quot;zip&quot;: &quot;517504&quot;   <br>   },   <br>   &quot;hobbies&quot;: [&quot;surfing&quot;, &quot;coding&quot;] <br>}</pre><p>So as we see, we are eliminating the need for traditional tables with all those rows and columns involving complex queries to retrieve data. Mongo DB makes it much easier to perform the CRUD operations on the data stored in the database. Let’s see it in action.</p><p>First things first, to use Mongo DB in your application you need to install their server. You can either start free by downloading their <a href="https://www.mongodb.com/download-center/community">community server</a> or if you can afford a subscription you can download their <a href="https://www.mongodb.com/download-center/enterprise">enterprise server</a> which will have some added benefits. For this tutorial we are just gonna go with the community server. Once you downloaded and installed it in auto settings that will pretty much be it.</p><p><strong>Then create a folder <em>data </em>at the same directory in which Mongo DB is installed with another folder <em>db </em>inside it. (Important!)</strong></p><p>That’s pretty much it and we are good to go. Now just to make sure we have installed everything properly open the command line and run the command</p><pre>&gt; mongo --version</pre><p>If it returns the version of MongoDB shell along with some other parameters, congratulations!! You have successfully installed Mongo DB. If not, don’t get disappointed. 8 out of 10 unsuccessful installations is because of the missing environment variables. So create the required environment variables and assign them with mongo’s bin folder. If you don’t know how, be sure to check out <a href="https://medium.com/chingu/an-introduction-to-environment-variables-and-how-to-use-them-f602f66d15fa">this</a> article. Now we can start our server by using the command :</p><pre>&gt; mongod</pre><p>It might be overhead at first, but at the end if you see <em>waiting for connection on port 27017, </em>then the server is started. Now you might wanna leave this terminal as it is for the rest of the tutorial. You can also use a third party terminal like <a href="https://hyper.is/">Hyper</a>, which can support multiple tabs to avoid opening command prompt for 3 or 4 times again and again. Now open another tab or terminal and give the command :</p><pre>&gt; mongo</pre><p>This command will start the mongo shell to interact with the database and will be waiting for the query. Now the Mongo DB query, unlike the traditional SQL, is a simple function call. First let us look at the existing databases. To do so give the command :</p><pre>&gt; show dbs</pre><p>It will show the two default databases along with their sizes.</p><pre>admin       0.000GB <br>local       0.000GB</pre><p>To create a new database or to use an existing database we can use the following query :</p><pre>&gt; use NewDatabase</pre><p>which will return :</p><pre>switched to db NewDatabase</pre><p>To see which database you are currently in, use :</p><pre>&gt; db</pre><p>Since Mongo DB uses documents to store data instead of tables, these documents are called collections. To view the collections inside a database, use the query :</p><pre>&gt; show collections</pre><p>It will show the collections inside a database if any. Now, to use a new collection we can directly give the insert query which will also create the collection without an additional step.</p><pre>&gt; db.myNewFoodCollection.insertOne({<br>    recipeName: &#39;Pav Bhaji&#39;,<br>    category: &#39;Snack&#39;<br>  })</pre><p>which will again return a document of acknowledgment:</p><pre>{ <br>        &quot;acknowledged&quot; : true,<br>        &quot;insertedId&quot; : ObjectId(&quot;5ec7ed74685a5bdcc007afbf&quot;)<br>}</pre><p>To read a document we can use the find query, which looks something like this :</p><pre>&gt; db.myNewFoodCollection.find()<br>{ &quot;_id&quot; : ObjectId(&quot;5ec7ed74685a5bdcc007afbf&quot;), &quot;recipeName&quot; : &quot;Pav Bhaji&quot;, &quot;category&quot; : &quot;Snack&quot; }</pre><p>Now to update a document, we can use the update query as follows :</p><pre>&gt; db.myNewFoodCollection.updateOne( <br>    {recipeName: &quot;Pav Bhaji&quot;},<br>    {$set: {category: &quot;All-time snack&quot;}}<br>  )</pre><pre>{ &quot;acknowledged&quot; : true, &quot;matchedCount&quot; : 1, &quot;modifiedCount&quot; : 1 }</pre><pre>&gt; db.myNewFoodCollection.find()<br> <br>{ &quot;_id&quot; : ObjectId(&quot;5ec7ed74685a5bdcc007afbf&quot;), &quot;recipeName&quot; : &quot;Pav Bhaji&quot;, &quot;category&quot; : &quot;All-time snack&quot; }</pre><p>Finally, to delete a document, we can use the delete query.</p><pre>&gt; db.myNewFoodCollection.deleteOne({_id:&quot;5ec7ed74685a5bdcc007afbf&quot;})</pre><pre>{ &quot;acknowledged&quot; : true, &quot;deletedCount&quot; : 0 }</pre><p>This pretty much sums it up the CRUD operations using Mongo DB shell. You can know more about other queries by reading their official documentation <a href="https://docs.mongodb.com/manual/">here</a>. If you’ve reached here following all the steps, thanks for taking the time to give this a read, and also feel free to comment your questions/suggestions. In the <a href="https://link.medium.com/jMZt2R4KL6">next article</a> I will share how MongoDB becomes a powerful tool when combined with a web framework like Node js.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c63d1e7193cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>