{"id":1127,"date":"2017-10-17T11:56:10","date_gmt":"2017-10-17T08:56:10","guid":{"rendered":"https:\/\/community.virtono.com\/?p=1127"},"modified":"2020-06-10T16:51:31","modified_gmt":"2020-06-10T13:51:31","slug":"mongodb","status":"publish","type":"post","link":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/mongodb\/","title":{"rendered":"MongoDB"},"content":{"rendered":"<header class=\"entry-header\">\n<h3 id=\"seriesName\">Series:\u00a0Introduction to the MEAN Stack<\/h3>\n<ul id=\"seriesList\">\n<li><a href=\"https:\/\/wp.me\/p7ISfL-hs\" target=\"_blank\" rel=\"noopener\">Part 1: Definition of the MEAN stack<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/p7ISfL-hz\" target=\"_blank\" rel=\"noopener\">Part 2:\u00a0Setup of the MEAN stack<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/p7ISfL-hC\" target=\"_blank\" rel=\"noopener\">Part 3:\u00a0Node.js<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-npm\" target=\"_blank\" rel=\"noopener\">Part 4:\u00a0npm<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-connect\" target=\"_blank\" rel=\"noopener\">Part 5:\u00a0Connect<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-express\" target=\"_blank\" rel=\"noopener\">Part 6:\u00a0Express<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-mongodb\" target=\"_blank\" rel=\"noopener\">Part 7:\u00a0MongoDB<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-mongodb\" target=\"_blank\" rel=\"noopener\">Part 8:\u00a0Mongoose<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-rest\" target=\"_blank\" rel=\"noopener\">Part 9:\u00a0REST<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-baucis\" target=\"_blank\" rel=\"noopener\">Part 10:\u00a0Baucis<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/s7ISfL-bower\" target=\"_blank\" rel=\"noopener\">Part 11:\u00a0Bower<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/p7ISfL-i1\" target=\"_blank\" rel=\"noopener\">Part 12:\u00a0AngularJS<\/a><\/li>\n<li><a href=\"https:\/\/wp.me\/p7ISfL-i4\" target=\"_blank\" rel=\"noopener\">Part 13:\u00a0Restangular<\/a><\/li>\n<\/ul>\n<\/header>\n<div class=\"entry-content\">\n<p>So far our server has only returned static data: files from the hard drive or texts stored in the source code.\u00a0In order to integrate data dynamically, the NoSQL database\u00a0MongoDB is\u00a0used\u00a0in the MEAN stack\u00a0.\u00a0In today&#8217;s article I explain to you the term NoSQL and how you use MongoDB with\u00a0Node\u00a0.<br \/>\n<span id=\"more-3626\"><\/span><\/p>\n<p>The definition of a NoSQL database is somewhat spongy.\u00a0The &#8220;No&#8221; is not for &#8220;not&#8221;, but for &#8220;Not only&#8221;, &#8220;Not only SQL databases&#8221;.\u00a0The term was introduced\u00a0with this meaning in\u00a02009 by Johan Oskarsson to describe all non-relational databases.\u00a0However, the architecture of non-relational databases can be very different, requiring further subdivision.\u00a0MongoDB belongs to the group of\u00a0<strong>document-oriented databases<\/strong>\u00a0.\u00a0Here are\u00a0<strong>documents<\/strong>\u00a0whose structure can be freely determined, the data are stored in the database.\u00a0(By comparison, MySQL stores data in tables.)<\/p>\n<p>The MongoDB documents are stored in the so-called\u00a0<strong>BSON<\/strong>\u00a0format, a JSON-like binary format.\u00a0Queries to the database are executed in JavaScript.\u00a0MongoDB is, by the way, the most\u00a0\u00a0common NoSQL database\u00a0.<\/p>\n<p>While MongoDB can also be controlled via the terminal, this article series skips this step and shows the use of MongoDB with Node without any detours.\u00a0We only need the terminal once to start MongoDB:<\/p>\n<div>\n<div class=\"codecolorer-container powershell default\">\n<table cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"line-numbers\">\n<div>1<\/div>\n<\/td>\n<td>\n<div class=\"powershell codecolorer\">$ mongod<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>After MongoDB is initialized, we install in a new project folder Express together with the\u00a0official MongoDB driver\u00a0for Node.\u00a0To download multiple modules at once with npm, you need to list several module names:<\/p>\n<div>\n<div>\n<div class=\"codecolorer-container powershell default\">\n<table cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"line-numbers\">\n<div>1<\/div>\n<\/td>\n<td>\n<div class=\"powershell codecolorer\">$ npm install express mongodb<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Now Express and the MongoDB driver are installed.\u00a0For the following example &#8211; we wrote everything back into a\u00a0<code class=\"codecolorer powershell default\"><span class=\"powershell\">server.js<\/span><\/code>file &#8211; we split the source code into two parts.\u00a0In the first part, we create a connection to our MongoDB database and create a\u00a0<strong>collection<\/strong>\u00a0.\u00a0A collection is a group of related documents.\u00a0In our example we want to save the visits of our website, so we call the collection\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visitsCollection<\/span><\/code>:<\/p>\n<div>\n<div class=\"codecolorer-container javascript default\">\n<table cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"line-numbers\">\n<div>1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<\/div>\n<\/td>\n<td>\n<div class=\"javascript codecolorer\"><span class=\"kw2\">var<\/span>\u00a0MongoClient\u00a0<span class=\"sy0\">=<\/span>\u00a0require\u00a0<span class=\"br0\">(\u00a0<\/span><span class=\"st0\">&#8216;mongodb&#8217;\u00a0<\/span><span class=\"br0\">)<\/span>\u00a0.\u00a0<span class=\"me1\">MongoClient\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\n<span class=\"kw2\">var<\/span>\u00a0visitsCollection\u00a0<span class=\"sy0\">;\u00a0<\/span><br \/>\nMongoClient.\u00a0<span class=\"me1\">connect\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"st0\">&#8216;mongodb: \/\/ localhost 27017 \/ first-db&#8217;\u00a0<\/span><span class=\"sy0\">,\u00a0<\/span><span class=\"kw2\">function\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0err\u00a0<span class=\"sy0\">,<\/span>\u00a0db\u00a0<span class=\"br0\">)\u00a0<\/span><span class=\"br0\">{\u00a0<\/span><br \/>\n<span class=\"kw1\">if\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0err\u00a0<span class=\"br0\">)<\/span><br \/>\n. console\u00a0<span class=\"me1\">log\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0err\u00a0<span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\n<span class=\"kw1\">else<\/span><br \/>\nvisits collection\u00a0<span class=\"sy0\">=<\/span>\u00a0db.\u00a0<span class=\"me1\">collection\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"st0\">&#8216;visits&#8217;\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\n<span class=\"br0\">}\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;<\/span><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>In the first line, we load the module\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">mongodb<\/span><\/code>from which we\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">MongoClient<\/span><\/code>\u00a0need it.\u00a0In the second line, we declare the previously mentioned variable\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visitsCollection<\/span><\/code>, which we will need later.\u00a0We then\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">MongoClient<\/span><\/code>\u00a0connect to our database\u00a0via\u00a0a link.\u00a0The URL\u00a0mongodb: \/\/ localhost: 27017 \/\u00a0is the default URL for a local MongoDB installation.\u00a0The suffix<code class=\"codecolorer powershell default\"><span class=\"powershell\">first<span class=\"sy0\">-<\/span>db<\/span><\/code>\u00a0the name is our database.\u00a0Moment!\u00a0We have not yet created a database with this name.\u00a0How should we connect to this?\u00a0This is not a problem.\u00a0MongoDB automatically creates a database with this name the first time it is requested.\u00a0After the URL, a callback is passed as the second parameter.\u00a0You can recognize a typical pattern of Node: Callbacks often pass two parameters, the\u00a0<strong>first parameter being<\/strong>\u00a0an\u00a0<strong>error object<\/strong>\u00a0and the\u00a0<strong>second parameter being<\/strong>\u00a0the actual\u00a0<strong>result<\/strong>\u00a0.\u00a0It is then possible to quickly check whether an error has occurred in order to output and intercept it accordingly.\u00a0The actual result of this callback is a<code class=\"codecolorer javascript default\"><span class=\"javascript\">db<\/span><\/code>Object that exposes an API to our database.\u00a0If no error has occurred, we would like to\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">db<\/span><\/code>\u00a0receive an access to our collection\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visits<\/span><\/code>\u00a0, which we\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visitsCollection<\/span><\/code>\u00a0store\u00a0in the variable\u00a0.\u00a0Also applies to collections: We do not have to\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visits<\/span><\/code>\u00a0create\u00a0a collection with the name before\u00a0, MongoDB automatically creates one, if not already exists.<\/p>\n<p>What do we want to do\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visits<\/span><\/code>\u00a0next\u00a0with the collection\u00a0?\u00a0You should save the visitors of our website.\u00a0For this purpose we will create a new document, ie a new database entry, which contains the requested URL and the time of the visit.\u00a0All previous visits are to be displayed.\u00a0To achieve this, we need the second part of our server, which we create with Express:<\/p>\n<div class=\"codecolorer-container javascript default\">\n<table cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"line-numbers\">\n<div>1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<br \/>\n10<br \/>\n11<br \/>\n12<br \/>\n13<br \/>\n14<br \/>\n15<br \/>\n16<br \/>\n17<br \/>\n18<\/div>\n<\/td>\n<td>\n<div class=\"javascript codecolorer\"><span class=\"kw2\">var<\/span>\u00a0express\u00a0<span class=\"sy0\">=<\/span>\u00a0require\u00a0<span class=\"br0\">(\u00a0<\/span><span class=\"st0\">&#8216;express&#8217;\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\nexpress\u00a0<span class=\"br0\">(\u00a0<\/span><span class=\"br0\">)<\/span><br \/>\n.\u00a0<span class=\"me1\">get\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"st0\">&#8216;*&#8217;\u00a0<\/span><span class=\"sy0\">,\u00a0<\/span><span class=\"kw2\">function\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0req\u00a0<span class=\"sy0\">,<\/span>\u00a0res\u00a0<span class=\"br0\">)\u00a0<\/span><span class=\"br0\">{\u00a0<\/span><br \/>\n<span class=\"kw2\">var<\/span>\u00a0visit\u00a0<span class=\"sy0\">=\u00a0<\/span><span class=\"br0\">{<\/span><br \/>\nurl\u00a0<span class=\"sy0\">:<\/span>\u00a0req.\u00a0<span class=\"me1\">url\u00a0<\/span><span class=\"sy0\">,<\/span><br \/>\ntime\u00a0<span class=\"sy0\">:<\/span>\u00a0Date.\u00a0<span class=\"me1\">Now\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><br \/>\n<span class=\"br0\">}\u00a0<\/span><span class=\"sy0\">;<\/span><br \/>\nvisits collection.\u00a0<span class=\"me1\">insert\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0visit\u00a0<span class=\"sy0\">,\u00a0<\/span><span class=\"kw2\">function\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0err\u00a0<span class=\"sy0\">,<\/span>\u00a0doc\u00a0<span class=\"br0\">)<\/span>\u00a0<span class=\"br0\">{<\/span><br \/>\nvisitsCollection.\u00a0<span class=\"me1\">find\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"br0\">)<\/span>\u00a0.\u00a0<span class=\"me1\">toArray\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"kw2\">function\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0err\u00a0<span class=\"sy0\">,<\/span>\u00a0docs\u00a0<span class=\"br0\">)\u00a0<\/span><span class=\"br0\">{\u00a0<\/span><br \/>\n<span class=\"kw2\">var<\/span>\u00a0log\u00a0<span class=\"sy0\">=\u00a0<\/span><span class=\"st0\">&#8221;\u00a0<\/span><span class=\"sy0\">;<\/span><br \/>\n. docs\u00a0<span class=\"me1\">forEach\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"kw2\">function\u00a0<\/span><span class=\"br0\">(<\/span>\u00a0doc\u00a0<span class=\"sy0\">,<\/span>\u00a0index\u00a0<span class=\"br0\">)\u00a0<\/span><span class=\"br0\">{<\/span><br \/>\nlog\u00a0<span class=\"sy0\">+ =\u00a0<\/span><span class=\"st0\">&#8216;Visited&#8217;\u00a0<\/span><span class=\"sy0\">+<\/span>\u00a0doc.\u00a0<span class=\"me1\">url\u00a0<\/span><span class=\"sy0\">+\u00a0<\/span><span class=\"st0\">&#8216;on&#8217;\u00a0<\/span><span class=\"sy0\">+<\/span>\u00a0doc.\u00a0<span class=\"me1\">time\u00a0<\/span><span class=\"sy0\">+\u00a0<\/span><span class=\"st0\">&#8216;in. &#8216;\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\n<span class=\"br0\">}\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">,<\/span><br \/>\nres.\u00a0<span class=\"me1\">send\u00a0<\/span><span class=\"br0\">(<\/span>log\u00a0<span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\n<span class=\"br0\">}\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\n<span class=\"br0\">}\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;\u00a0<\/span><br \/>\n<span class=\"br0\">}\u00a0<\/span><span class=\"br0\">)<\/span><br \/>\n.\u00a0<span class=\"me1\">listen\u00a0<\/span><span class=\"br0\">(\u00a0<\/span><span class=\"nu0\">1337\u00a0<\/span><span class=\"sy0\">,\u00a0<\/span><span class=\"st0\">&#8216;127.0.0.1&#8217;\u00a0<\/span><span class=\"br0\">)\u00a0<\/span><span class=\"sy0\">;<\/span><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<p>Our server consists of a single middleware, which\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\"><span class=\"sy0\">*<\/span><\/span><\/code>\u00a0is valid\u00a0for the route\u00a0.\u00a0One\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\"><span class=\"sy0\">*<\/span><\/span><\/code>\u00a0is a special\u00a0<strong>placeholder<\/strong>\u00a0for Express, which is internally converted into a regular expression.\u00a0In this case, stands\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\"><span class=\"sy0\">*<\/span><\/span><\/code>\u00a0for any URL!\u00a0No matter what URL the server is addressed, the following middleware is always running.\u00a0At the beginning of the middleware, we create a\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visit<\/span><\/code>-Object with the URL and the time of the visit.\u00a0This is stored later exactly in the database.\u00a0The URL requested by the user can be\u00a0\u00a0queried\u00a0via\u00a0.\u00a0Using the method of\u00a0\u00a0the\u00a0object, the<code class=\"codecolorer javascript default\"><span class=\"javascript\">req.<span class=\"me1\">url<\/span><\/span><\/code><code class=\"codecolorer javascript default\"><span class=\"javascript\">insert<\/span><\/code><code class=\"codecolorer javascript default\"><span class=\"javascript\">visitsCollection<\/span><\/code><code class=\"codecolorer javascript default\"><span class=\"javascript\">visit<\/span><\/code>Object.\u00a0As a second parameter, the method expects a callback with the signature of an error and a result object.\u00a0After the save, the method of\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">find<\/span><\/code>\u00a0the\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">visitsCollection<\/span><\/code>object is used to retrieve all stored visits,\u00a0store them\u00a0in a string named\u00a0<code class=\"codecolorer javascript default\"><span class=\"javascript\">log<\/span><\/code>\u00a0formatted, and then\u00a0print them\u00a0over\u00a0\u00a0.\u00a0This is also true for any URL, because we are still in the same middleware.<code class=\"codecolorer javascript default\"><span class=\"javascript\">res.<span class=\"me1\">send<\/span><\/span><\/code><\/p>\n<p>If you now visit\u00a0http:\/\/127.0.0.1:1337\/\u00a0you get as output &#8220;Visited \/ server on 1380190257203.&#8221;, whereby with you the time will be different.\u00a0Tests various URLs like\u00a0http:\/\/127.0.0.1:1337\/test\/\u00a0or\u00a0http:\/\/127.0.0.1:1337\/sddasd\/\u00a0.\u00a0You can also use a different browser or restart the Node server.\u00a0The data will be retained and expanded on each visit.\u00a0You may also notice the URL &#8220;\/favicon.ico&#8221;, which you probably never entered yourself.\u00a0This is a URL, which most browsers call independently to download the so-called favicon of a page.\u00a0Your result should look something like this:<\/p>\n<div id=\"attachment_3629\" class=\"wp-caption aligncenter\">\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3629\" data-permalink=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-configure-a-private-docker-registry-in-ubuntu-22-04\/attachment\/screenshot-2023-06-26-at-10-31-06\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/06\/Screenshot-2023-06-26-at-10.31.06.png?fit=2880%2C614&amp;ssl=1\" data-orig-size=\"2880,614\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-2023-06-26-at-10.31.06\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/06\/Screenshot-2023-06-26-at-10.31.06.png?fit=300%2C64&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/06\/Screenshot-2023-06-26-at-10.31.06.png?fit=750%2C160&amp;ssl=1\" class=\" wp-image-3629\" src=\"https:\/\/i0.wp.com\/www.senaeh.de\/wp-content\/uploads\/2013\/10\/127.0.0.1_1337_day.png?resize=289%2C319\" alt=\"\" width=\"289\" height=\"319\" \/><\/p>\n<p class=\"wp-caption-text\">MongoDB and Node<\/p>\n<\/div>\n<p>The use of the MongoDB driver is very simple and intuitive.\u00a0Sometimes you want to have more control over the structure of your documents.\u00a0For this purpose, you can use the\u00a0Mongoose\u00a0framework\u00a0, which I will present to you in the next article.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Series:\u00a0Introduction to the MEAN Stack Part 1: Definition of the MEAN stack Part 2:\u00a0Setup of the MEAN stack Part 3:\u00a0Node.js Part 4:\u00a0npm Part 5:\u00a0Connect Part 6:\u00a0Express Part 7:\u00a0MongoDB Part 8:\u00a0Mongoose Part 9:\u00a0REST Part 10:\u00a0Baucis Part 11:\u00a0Bower Part 12:\u00a0AngularJS Part 13:\u00a0Restangular So far our server has only returned static data: files<\/p>\n","protected":false},"author":4,"featured_media":1128,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,3],"tags":[],"class_list":["post-1127","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase","category-tutorial-how-to"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/mongodb-1.jpeg?fit=1040%2C560&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s7ISfL-mongodb","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1089,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/setup-of-the-mean-stack\/","url_meta":{"origin":1127,"position":0},"title":"Setup of the MEAN stack","author":"Daniel Draga","date":"October 9, 2017","format":false,"excerpt":"Series:\u00a0Introduction to the MEAN Stack Part 1: Definition of the MEAN stack Part 2:\u00a0Setup of the MEAN stack Part 3:\u00a0Node.js Part 4:\u00a0npm Part 5:\u00a0Connect Part 6:\u00a0Express Part 7:\u00a0MongoDB Part 8:\u00a0Mongoose Part 9:\u00a0REST Part 10:\u00a0Baucis Part 11:\u00a0Bower Part 12:\u00a0AngularJS Part 13:\u00a0Restangular In this article, we will lay out the basics for\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/meanjs-1024x492.png?fit=1024%2C492&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/meanjs-1024x492.png?fit=1024%2C492&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/meanjs-1024x492.png?fit=1024%2C492&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/meanjs-1024x492.png?fit=1024%2C492&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1082,"url":"https:\/\/www.virtono.com\/community\/knowledgebase\/definition-of-the-mean-stack\/","url_meta":{"origin":1127,"position":1},"title":"Definition of the MEAN stack","author":"Shreyash Sharma","date":"October 9, 2017","format":false,"excerpt":"Series:\u00a0Introduction to the MEAN Stack Part 1: Definition of the MEAN stack Part 2:\u00a0Setup of the MEAN stack Part 3:\u00a0Node.js Part 4:\u00a0npm Part 5:\u00a0Connect Part 6:\u00a0Express Part 7:\u00a0MongoDB Part 8:\u00a0Mongoose Part 9:\u00a0REST Part 10:\u00a0Baucis Part 11:\u00a0Bower Part 12:\u00a0AngularJS Part 13:\u00a0Restangular In a new article series, I would like to\u00a0offer\u00a0you an\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Mean.jpg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Mean.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Mean.jpg?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Mean.jpg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Mean.jpg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1105,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/mongoose\/","url_meta":{"origin":1127,"position":2},"title":"Mongoose","author":"Shreyash Sharma","date":"October 12, 2017","format":false,"excerpt":"Series:\u00a0Introduction to the MEAN Stack Part 1: Definition of the MEAN stack Part 2:\u00a0Setup of the MEAN stack Part 3:\u00a0Node.js Part 4:\u00a0npm Part 5:\u00a0Connect Part 6:\u00a0Express Part 7:\u00a0MongoDB Part 8:\u00a0Mongoose Part 9:\u00a0REST Part 10:\u00a0Baucis Part 11:\u00a0Bower Part 12:\u00a0AngularJS Part 13:\u00a0Restangular Mongoose\u00a0is a framework which is based on the\u00a0native MongoDB driver\u00a0and\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/mongoose.png?fit=370%2C200&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":965,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-install-mongodb-on-debian-8\/","url_meta":{"origin":1127,"position":3},"title":"How to Install MongoDB on Debian 8","author":"Daniel Draga","date":"June 11, 2017","format":false,"excerpt":"Introduction Part of the MEAN stack MongoDB is the new\u00a0NoSQL document database that is being implemented within modern web applications. So using MongoDB in your own application will give it the edge, you will be able to deal with a large amount of data. On top of all that you\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/06\/mongodb-for-giant-ideas-bbab5c3cf8.png?fit=1024%2C512&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/06\/mongodb-for-giant-ideas-bbab5c3cf8.png?fit=1024%2C512&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/06\/mongodb-for-giant-ideas-bbab5c3cf8.png?fit=1024%2C512&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/06\/mongodb-for-giant-ideas-bbab5c3cf8.png?fit=1024%2C512&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3230,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-install-mongodb-on-ubuntu\/","url_meta":{"origin":1127,"position":4},"title":"How to install MongoDB on Ubuntu","author":"George B.","date":"April 13, 2023","format":false,"excerpt":"Welcome to this comprehensive guide on how to install MongoDB on Ubuntu! In the following steps, you will learn everything you need to know to set up MongoDB on your Ubuntu system. Whether you're a beginner or an experienced user, this guide will walk you through the installation process, providing\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/04\/How-to-install-MongoDB-Ubuntu-22.png?fit=600%2C330&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/04\/How-to-install-MongoDB-Ubuntu-22.png?fit=600%2C330&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/04\/How-to-install-MongoDB-Ubuntu-22.png?fit=600%2C330&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3687,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-mongodb-on-kubernetes\/","url_meta":{"origin":1127,"position":5},"title":"How to Deploy MongoDB on Kubernetes","author":"George B.","date":"July 29, 2023","format":false,"excerpt":"This tutorial will walk you through installing MongoDB on Kubernetes cluster. We'll assume that you've already got K3s and Helm set up on your machine. The deployment of applications like MongoDB on Kubernetes cluster is made easier by the Kubernetes package manager Helm. Before getting too technical, it's important to\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-MongoDB-on-Kubernetes.png?fit=360%2C240&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/1127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/comments?post=1127"}],"version-history":[{"count":2,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/1127\/revisions"}],"predecessor-version":[{"id":1186,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/1127\/revisions\/1186"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media\/1128"}],"wp:attachment":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media?parent=1127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/categories?post=1127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/tags?post=1127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}