MongoDB Getting Started 01
Key Takeaways
This video tutorial covers the basics of MongoDB, a non-relational database, including its installation, CRUD operations, and data storage, as well as interacting with the database using the Mongos driver and Mongoose module.
Full Transcript
help analyze how all you're doing welcome to new vestroia from IPOs this one you cannot explain or we're gonna just walk you through about manga database or MongoDB so if you're not familiar with this it's another type of database if you just familiar with my sequel databases or just sequel lines also there is the MongoDB already open up that also a MongoDB ends non sequel database which means non-rational database I will explain that in a second but it's a very very nice database especially for web developers or for web applications what projects in general and it's given give you a really really flexible like constructor of data gets stored and a very nice way to retrieve and store and save DN a-- and update and delete like the crew thinks so creates read update and delete from this database give you a really really nice things to manipulate that and it's free free for charge you use of course for at least for your own server and for your own small project and like for getting started so you can just firstly to download via this and install from your machine whether you're running Windows what extra macosx it's freely available for you so just go to the DB comm over you just go to download section over there and choose your server so go to the community server and here choose your Linux Mac OS X so I'm helping Windows and double the Amazon after that just quick on solids whatever he wants on whatever disk you want and make sure to remember which takes this do you have saved that on because this is gonna really like him being very important or very necessary when we try to sauce the service layer on and also I'm gonna like he use the projects over here so I'm gonna learn a boss one god how we can save or how can you connect to this database create database or collection as it's called on the man god namespaces and actually we're gonna use the light the beta's tutorial so the latest projects on this tutorial which is the pokémons api if if you haven't done this or you have watch this I really recommend going ahead and watch this because we're gonna use this code so we're gonna like we have in here if you had an take a look on the server so we've done and done this in just a small or stored the d end of the pokémons in a small array over here which is not the best thing to do and it's not good at all so you need to move this or move this data here to a real database that's why I'm gonna use MongoDB so we're gonna convert this into a database and just change what is need to be changed but before then I'm gonna just stop over there so as I've said after installing this also I need to explain something in you is the difference between a rational or sequel databases and non sequel databases so non sequel database on MongoDB is a non sequel database and for the sequel databases are my sequel sequel lined and a lot of other things like the Oracle database so for the sequel database to be zoom in a bit over you sequel database each just have the structure of the tables not familiar with table tasks columns and rows so each row has a couple of columns and so on and so forth so whatever or whenever you want to fetch data or save that the end of this database you need to like tell it which row in order to go and look for after you find the road tell us which column to insert the other for so let's say you want to like find the first year oh this is the first row and he wants to find the first column so you said go to the first row and ensure it's some data on the first column and yet I am I like the same thing happens when you try to achieve the end up in the sea from the sequel database rational database also it's called you couldn't just Google that and you're gonna like instead a lot of things also now for the non sequel database it doesn't work like this it works like a key value pair so if you are familiar with JavaScript objects or like JSON so they are there's the key and there is an objects and the objects can be any data type over the a media type you can do each house so or you can actually use and the key can be like in the index or a name or whatever an Austrian I believe and you can use it if you are familiar with the node graph so there's a node and a lot of nodes or connected to each other and depending on - using the key in volume person it's like it works it doesn't have the table structure in it's more flexible for that for kind of projects especially as I've said for web applications so this like the main differences between rational and non rational or no sequel databases you couldn't you can like search for more informations about both of these database types but yeah this is like the main thing you need to understand before giving on into like the MongoDB and the other thing I want to talk about is that since we are going to use the GSM here so as you might have noticed we're gonna use no genius in order to create the database manipulate all of this kind of theater so we need like a wrapper around the MongoDB you still can use the like official MongoDB release over there but I really do recommend going in ahead with the mono so the mongos overview it's a really really nice thing so you're just going to have in downloading it or it's modular over there available for nodejs a wrapper around the original one so you just go ahead and download it and you're good to go so just NPM can solve one goes and you're good to go make sure just bounce into a project now let me just go ahead and create a new like two files over here let's say let's call this I don't know DB test Janus and for the other one what we need actually is the model so we need to like to find a special schema for how our how actually our data is going to be stored on this kind of database so let's just go ahead and define a model and this is like called a model and the database or if you are familiar with MVC's like live or something like this so yeah so first things first what we need to do is create the model so how our DNA is going to be stored and since we're gonna just use some kind of a user's password and stuff so it's gonna be very simple so first things first we need to require the mando's just go ahead and say Mongo's equals require and find mongos it should pop off for you and obviously now we need to work wire the scanner so mongos has this cannot already predefined so make sure to require this object Mon or call it's canna equals I can't tie for something so so one girl stop the skimmer you should find that right out of the box over there and we just leave this line that has been automatically right so yeah this should work now I think rightfully the scanner guess it comes to lettuces it's two plants so we can use it right now now we need to define or create a new scanner so that's I don't know let's call this like users so this is gonna be like the users of scanner and equals new scan of course and here we can pass in an object and this object can have your structure your database structure so you can use whatever like when you put something like the name over here this is gonna be like your field so the name is going to be the key and whenever you insert some data into this you can insert into the follows so it's gonna be the key and a value appears over here so it just works as simple as that and you can insert multiple fields or multiple attributes or key value pairs over here and so on and so forth and you can store any data types operator so for example I'm gonna use like a username and the password so we're using etiquette but it's also an object in here and to find some kind of things so you can define the type that this is gonna be using and for for this case username is going to be string so you can put the string and also you can put the required field which means this field is like specifically required whenever you submit data this field should not be empty so you must fill in this field and you can post the longer thing is let's say password for example and also you can put the tie this terminus of attributes you can manipulate over you so just checking the mongos or the MongoDB the the documentation it's gonna give you the guide where to what what to use actually over all the reference that you need so here the type also is going to be string I'm also going to be required so it's very simple and so also we say quiet equals true you can also add some kind of other dates so let's say for created created adds some attribute is gonna solve whenever or when the actual user in has been registered on the server so let's say there's going to take a time and also you can even declare custom types over here and what I mean by custom size you can put object types on you for example the daystate is a building objects from javascript so you can just put it all right on the box and it's gonna do the job for you that's why really with a nice thing and also you can put a default value for this so you don't need specifically to you need to insure this whenever you create a new user so you need to insert or co-creator that's the the data or the volume is going to be inserted by default so you can put dates but now function and is gonna do the job for us so yeah that's very simple this is how we gonna work so how actually our schema is very very basic and very simple so you can add a lot of other fields over here and you can manipulate it however you want and here what we can do is use the exports keyword or no GS keyword in order to work things out so here we can put um like user equals let's say multiple that's her over your knee holes and mangoes has a specific method lagana converge or compile this schema into a real world model so it's called model by the way and here you puts your model name for example that I put up kids the user and we put our schema so it's gonna be an user from the web so the schema we have just to point out with that now everything is set up correctly now you just go to the database test and we need to require this but first what we need is actually to go ahead and connect to our database and for that also obviously we're gonna need to like Mongo's modulus require one goes over you so it's not actually work so mongols issued to the job Pena and Margo's is being like successfully imported now when it also to get this model so we can do like a user equals require can usually require require our custom files over here so we can say this M although and we can tell it to use the user so yeah here we are on pouring this model over here which going to be compiled for us from the skin so it's very simple you're gonna use it like this it's very very simple very basic and actually very very nice to use over here now we need to connect like connect to the database and for connecting to the database like you don't need to create the database actually just supply the name in gonna do the job or the rest of the job automatically for you what I mean by this if the database is already has been created it just gonna open it and start or like link you with this instance and return the instance so you can work with it right out-of-the-box but rather than if it's not or otherwise if it's not created it's just gonna create for you and which are the instance it so we're gonna just do that automatically for you so you'll need to worry about creating a database or no and before just trying to connect the database what we need actually cue like run the MongoDB serve or service action so make sure to like CD into the main title choice so let's say you have like gone and on song with the a MongoDB into the lock of this V or the couple the binarism to the mall walking the CD make sure to see the overview to low-cost say CBD and CD into them if you have install it into local disk C make sure to see the over there so this is like what I was saying because if you don't since I mean like like an install it seem to local the city on I'm CD in there so if you don't do this like it gonna give you a really really weird error that you're not gonna understand actually so make sure to do it like this that way you're gonna work some now just type in Hmong God after a sign of course the mango executable from dust on its on your machine and press enter and as I've said make sure to do this now the service is being good like initiated just wait till you see listening so until you see this message waiting for connection on course 27:17 so this is like the default port you can change this by passing some options on the command line but this is going to do the dog for us very perfectly so yeah so 27 out 17 is the port gonna work on now the service is running so let me just open up a new terminal so I'm gonna use it to run this one for that we're gonna just call the and the cuneta method to connect method need to be supplied with a URI and that your line is a specifically user or using this mangled protocol so say MongoDB and like here you put in your local host this we're running but localhost or you put in your remote server and over here you say I believe this is only to yourself yeah and I mean and the other one is you puts forward slash then your database name so if you want to create any database anything at all just put in here yeah name for me let me just name this database users and yeah we're good to get right now now this you're gonna create for us automatically into the MongoDB and I'm gonna save it for us and return the instance and try to connect and the other thing or the second parameter is just a bunch of like options to pass in overview and the third one which I'm going to use is a call back I'm gonna be called once this database is started successfully or not so there's an error so we could check in we're just gonna console the log error and over here Sarah and we're gonna say error else we're gonna just console.log service attorney so we're gonna console.log the MongoDB DB has been started successfully so I don't think I can just like type in correctly or spelling correctly so I'm doing with this guys now whatever they like the DB server is going to be storing or we link or connect to our database a new message like an anchor pop up DB has been successfully started now what we actually need to do is to retrieve some data to retrieve the data that or like save at the end into the database so to save their own database only need to do save so let me just save enough on database all I need to do is call the like create in your scanner so you see this model that we have just compiled it over you well with the schema so from this game of compliantly model so now we can use this model in order to please in your model so each model overview represents a single user so we can create a bunch of users you can create whatever let just try to create a new user now actually to save to the database what we need to do is the same mongos and unfortunately like this so we need to create a new instance of the user so each one we create that it represents one single user so we can do that stuff this the model that have just compiled from the schema so since we have imported it over here into the user what we can do is let's our some kind of robot equals a new user called robots equals new user and here you put in the user dead so here you put in your objects and it utopian so for this I'm gonna put the username for example robots and putting the password for example are not one two three four simple steps now you have created that and now after creating the instance what we need is to save the instance into the database so using the safe method and here the safe method takes a callback so when the save is finished you're gonna just call this callback or call the callback actually and takes an error and it takes another one is the user so the user we have just answered this like the user geared up of the use of objects and we check if error I'm gonna just console the log not save and else you can console log the user again so yeah this should be like very very simple thing and another thing I want to mention about should put the MongoDB not only over here so I've just put in Monga over here not gonna work and make sure to specify the database or better call the collection name over you know the to make it work so yeah that should work for now now we should go ahead and just try to do or just go to now to learn MongoDB which is over here let MongoDB and for slash database 10-spoke giants and this should let us know that we have created that and connected to database first so we have seen this everything is working ok everything's working fine and the second thing we get our a user so the users logged out which means the user has been successfully saved into the database with the username or frobots and the password one two three four and as you can see here you can notice is a unique ID which starts with an underscore ID and it's like a really random big number over here so what this is actually is like MongoDB cannot search a unique ID for each item you insert into the database no matter what so you can disable this but I really do recommend not because this doing a really nice work and it's uniquely writes himself yeah no worries about this and the other thing wanna mention before we finish in this video is this like this campus link program or software that gonna allow you to check out your database in a GUI interface which means a graphical user interface so whenever like an you install the MongoDB this gonna comes pre pre-installed with it so we're just gonna open it or search for it in open and then connect some database just let me just disconnect over here I'm gonna find it over here just let the settings host the same port and over here so just click connects and it just gonna take you to your database and here you can sell that's all of them our databases this our database now if we try to access the first u.s. used database you can find here the episode of the robust and one two three four and you come in a place find the leads from over you and you can just do some testing whenever you try to create your application and just some failed or reserve box for you so it's gonna be very simple in the next one so this was a very introductory thing just trying to save some arbitrary data into the database and show you how everything actually works so in the next one we're gonna just take this Pokemon API and try to re-implement it in order to make it supports a MongoDB and make everything works fine so the next one I'm gonna take this or take a closer look on that and we're gonna you're just gonna learn more about updating deleting and finding on the MongoDB or using the mongos in order to find out the MongoDB collection or database so a lot of this actually guys are very simple very basic I will catch you in the next one
Original Description
Full Tutorial:
http://go.ipenywis.com/ipeny539f
--- Official Links----
Official Website: http://ipenywis.com
Official Facebook: http://go.ipenywis.com/ipeny4907
Official Twitter: http://go.ipenywis.com/islem9a03
Official GitHub Repo: http://go.ipenywis.com/ipeny5c0e
---Support US---
By Becoming a Patreon: http://go.ipenywis.com/ipeny5024
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from CoderOne · CoderOne · 29 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
▶
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Laravel CMS | N-01 | Getting Started and Environment Set Up
CoderOne
Laravel CMS | N-02 | Routes, Controllers and Views
CoderOne
Laravel CMS | N-03 | Dealing With Assets and Page Layouts
CoderOne
Laravel CMS | N-04 | Migration, Models and Adding Categories
CoderOne
Laravel CMS | N-05 | Showing Added Categories, and Session Messages
CoderOne
Laravel CMS | N-06 | Edit\Remove Categories using AJAX and Popups
CoderOne
Laravel CMS | N-07 | Add New Post
CoderOne
Laravel CMS | N-08 | Creating a Basic Laravel Blog
CoderOne
HTML5 Canvas For Beginners | Getting Started | #01 with Webpack
CoderOne
HTML5 Canvas For Beginners | Drawing Basic Shapes | 02
CoderOne
HTML5 Canvas | Drawing Text With Circles | Part 01
CoderOne
HTML5 Canvas | Text Animation and Circle Collision | Part 02
CoderOne
Complete Guide To Web Development In 2018
CoderOne
AJAX & JSON Explained | Examples
CoderOne
Visual Studio Code Web Development Setup and Extensions
CoderOne
Electron Build Desktop Apps HTML/CSS/JS - Getting Started 01
CoderOne
Electron Build Desktop Apps HTML/CSS/JS | Creating Windows and Processes 02
CoderOne
Electron Build Desktop Apps HTML\CSS\JS | Dialog, Sessions and Cookies 03
CoderOne
Electron Build Desktop Apps HTML\CSS\JS | Custom App Menu & Context Menu 04
CoderOne
Electron Build Desktop Apps HTML\CSS\JS | Package, Build and Deploy your App 05
CoderOne
Node.js Brief Beginners Introduction #01
CoderOne
Node.js How Modules Works & NPM #02
CoderOne
Node.js Working With Events and Event Emitter #03
CoderOne
Node.js File System (Read and Write) FS 04
CoderOne
Node.js Create a Basic Server Using Express 05
CoderOne
Json Web Token Authentication JWT Explained Securing API
CoderOne
CSS Flex Box Design | Practical Examples |
CoderOne
API How It Works With Practical Examples
CoderOne
MongoDB Getting Started 01
CoderOne
MongoDB Working with APIs and Practical Examples
CoderOne
Create a Command Line Interface (CLI) Using Node JS #01
CoderOne
Create a Command Line Interface (CLI) Using Node JS 02
CoderOne
Build React Apps | Introduction And Getting Started #01
CoderOne
Build React Apps | Working With Components And Multiple Rendering #02
CoderOne
Build React Apps | App State Management | Practical Examples #03
CoderOne
Build React Apps | Getting Started With Flux (Intro) #04
CoderOne
Build React Apps | Create a Clock Timer Using React 05
CoderOne
Build React Apps | Create a Clock Timer Using React 05 | PART2|
CoderOne
CSS Preprocessors Getting Started | SASS and LESS | Practical Examples
CoderOne
Regex Introduction | Learn Regular Expressions 01
CoderOne
PHP VS Node.js Which is Best For Web Development
CoderOne
Drag and Drop Using Native Javascript 01
CoderOne
Drag And Drop Using Native Javascript 02
CoderOne
Master Git (Version Control) in One Video From Scratch
CoderOne
Let's Learn The New Javascript ES6 Class Syntax
CoderOne
Let's Create A BlockChain On Node.js
CoderOne
Best Online Code Editors For Web Developers
CoderOne
Let's Create a Modern Login Form on React #01
CoderOne
Let's Create a Modern Login Form on React #02
CoderOne
Laravel CMS | N-09 | Admin Registration
CoderOne
Laravel CMS | N-10 | Login and Authentication
CoderOne
Let's Create a Twitter Bot (Listen and Retweet)
CoderOne
Rapid Webpage Creation With Emmet (HTML & CSS)
CoderOne
Create Popups and Modals Using Native Javascript, HTML and CSS
CoderOne
Promises and Callbacks on Javascript With Practical Examples
CoderOne
Create Collapses using Native Javascript, HTML and CSS
CoderOne
Let's Learn Typescript (Javascript Devs) | Getting Started 01
CoderOne
Let's Learn Typescript | Interfaces and Generic Types (The Typing System) 02
CoderOne
Let's Learn Typescript | Work With Classes, Modules and Enums 03
CoderOne
Let's Learn Typescript | React and Webpack With TS 04
CoderOne
More on: LLM Foundations
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
n8n Automation Repurpose Video Content: The 2025 Production Guide
Dev.to AI
You’re Still Paying $200/Month for AI Tools You Could Replace With a Free Local Setup Tonight
Medium · Data Science
Top 10 AI Tools Every College Student Should Know in 2026
Medium · AI
Answer Calculator: Step-by-Step Math Help
Medium · Machine Learning
🎓
Tutor Explanation
DeepCamp AI