MERN Stack Tutorial #4 - MongoDB Atlas & Mongoose

In this MERN tutorial we'll set up a database using MongoDB Atlas, and then connect to it from our application using a package called Mongoose.
⭐⭐ Get the full course now (without ads) on the Net Ninja Pro site:
netninja.dev/p/mern-stack-tut...
⭐⭐ Get access to all free & PREMIUM courses on Net Ninja Pro:
net-ninja-pro.teachable.com/p...
🥷 Course Files (GitHub):
github.com/iamshaunjp/MERN-St...
💻 Node.js & Express Crash Course:
On Net Ninja Pro - netninja.dev/p/node-js-crash-...
On KZread - • Node.js Crash Course T...
💻 MongoDB Crash Course:
On Net Ninja Pro - netninja.dev/p/complete-mongo...
On KZread - • Complete MongoDB Tutor...
💻 React Full Courses:
On Net Ninja Pro - netninja.dev/p/build-websites...
On Udemy - www.thenetninja.co.uk/udemy/r...
On KZread - • Full React Tutorial #1...
🔥🔥🔥 Other resources:
React Context & Hooks tutorial (on KZread) - • React Context & Hooks ...
VS Code - code.visualstudio.com/
MongoDB Atlas -www.mongodb.com/atlas/database
POSTMAN - www.postman.com/downloads/

Пікірлер: 94

  • @estoriassurreais3434
    @estoriassurreais34342 жыл бұрын

    Man, you are the best dev teacher, what others take 10 hours, you teach in 8 min video :D love you

  • @raufukiwala

    @raufukiwala

    2 жыл бұрын

    You can say that again friend

  • @gshock1485
    @gshock1485 Жыл бұрын

    You just gained a subscriber man. By now I've watched a 60h udemy course and a few other courses on KZread, most of them around 6-10h. However, it was you who cleared my concepts properly. They did teach a lot more and dug deep into every concept and im sure that it'll only help in the long run but for someone who's beginning their journey, id certainly prefer concise to the point explanations with a very high level overview of the subject. We will learn more about it along the journey. That's why I loved your tutorial. Thank you. Sure, watching those previous videos certainly did help in grasping your code faster and so to anyone reading this comment and is a beginner like me, please watch as many videos as possible. You never know what clicks for you. This one did for me.

  • @amkamwebavenger3870
    @amkamwebavenger38702 жыл бұрын

    The course is going well and I'm finally learning the MERN the real and comprehensive way. Thanks so much my Ninja. Much love bro, you're the best.

  • @hadibaalbaki5097
    @hadibaalbaki50972 жыл бұрын

    super excited for this series, I've been searching forever for a good MERN course and i can't believe i found you starting a new one

  • @raufukiwala
    @raufukiwala2 жыл бұрын

    I will admit I have tried before following say 7-hour mern stack tutorials but still, I was struggling with simple things. This series is different, I'm now able to digest everything and watch every piece come together. Even the basic REST CRUD operations in video #3 are so concise that I now fully got the concept. Hopefully, I will be able to code a simple to-do app using the knowledge I will acquire from this series. Thank you so much NetNinja

  • @deepkodes4434

    @deepkodes4434

    10 ай бұрын

    yess unless you understand the simple projects and drill down the basics, big projects dont make any sence.

  • @georgeolufemi4285
    @georgeolufemi42852 жыл бұрын

    Can't wait for the full tutorial and the Authentication tutorial too. Learning simplified 👌🏽. Thank you Netninja.

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thanks George :)

  • @slicknature

    @slicknature

    2 жыл бұрын

    @@NetNinja I can’t wait as well! When is authentication series coming out?

  • @Stevenalp18
    @Stevenalp188 ай бұрын

    This dude is great! He literally taught me what a bootcamp tried to teach, but they confused me more, the crazy part is, he does it for FREE! I subscribed and joined his group, definitely deserves the support yall!

  • @NetNinja

    @NetNinja

    8 ай бұрын

    Thanks Steven, that means a lot :)

  • @interfacts11
    @interfacts112 жыл бұрын

    What you have done for us it is amazing! and we really like your Mern Stack videos. Please don't stop teaching. We are looking forward to your lesson! Thanks a lot! Ninja dev

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thanks Husan :) much appreciated!

  • @radiantreflaction
    @radiantreflaction2 жыл бұрын

    Thank u for this awesome series..love the way you explain things...plz upload 2 videos in a day if possible

  • @margaretwhyte2514
    @margaretwhyte2514 Жыл бұрын

    I'm so glad I found this! Learning has never been this interesting and easy. Thank you so much!!!!!!!

  • @NetNinja

    @NetNinja

    Жыл бұрын

    You're very welcome Margaret :) thanks for watching

  • @rakinar2
    @rakinar22 жыл бұрын

    Cool! I absolutely loved this tutorial!

  • @thevooiiD
    @thevooiiD2 жыл бұрын

    You people are just doing great work.👌 Don't stop.

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thanks Amit :)

  • @mrgrossartig
    @mrgrossartig Жыл бұрын

    Great tutorial, thank you. 😊

  • @andersonsimeon4172
    @andersonsimeon41722 жыл бұрын

    Wow.. U posted the course just when I needed it.. Thank you very muchh...

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Awesome, hope it was helpful Anderson! :)

  • @yinonb172
    @yinonb1722 жыл бұрын

    Thanks sensei !!

  • @user-jv9pg7gt2y
    @user-jv9pg7gt2y Жыл бұрын

    awesome! Thank u

  • @patrinov
    @patrinov9 ай бұрын

    You saved me a lot of head banging, thanks alot

  • @johnpaulpineda2476
    @johnpaulpineda24762 жыл бұрын

    Ow yes. Thanks shaun!

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thanks John :)

  • @alexg7282
    @alexg72822 жыл бұрын

    Thank you !

  • @valeriynehovora6652
    @valeriynehovora66522 жыл бұрын

    Had a problem with the connection DB, because my password for DB contained the symbol '@' . Do not use it!🙂 Thank you a lot for the tutorial!

  • @TRAILER_ROLLERCOSTING
    @TRAILER_ROLLERCOSTINGАй бұрын

    Thanks man,i've been having issues connecting to mongo this helped me

  • @NetNinja

    @NetNinja

    Ай бұрын

    Awesome, glad it helped :)!

  • @rajnishkushx
    @rajnishkushx5 ай бұрын

    You're the best, i subscribed you right away, ser

  • @jumhuur
    @jumhuur2 жыл бұрын

    thanks so muck ninja

  • @alihamoud6863
    @alihamoud68632 жыл бұрын

    All love ❤

  • @ghofranedarragi5601
    @ghofranedarragi5601 Жыл бұрын

    thanks , like always simple and clear explanation

  • @NetNinja

    @NetNinja

    Жыл бұрын

    You're welcome! :) hope it was useful

  • @ghofranedarragi5601

    @ghofranedarragi5601

    Жыл бұрын

    @@NetNinja yes it was ^^

  • @shawn.builds
    @shawn.builds Жыл бұрын

    Fire!!!!!!

  • @kim92se64
    @kim92se642 жыл бұрын

    going so well

  • @mdsafikulislam9113
    @mdsafikulislam91132 жыл бұрын

    Thanks

  • @AdamCanDoIt
    @AdamCanDoIt Жыл бұрын

    Wow, your videos are great, keep up the great work! Quick question, how would I host something like this in the end (ideally for free)? Could I use something like Vercel, or does that not allow express? And would you you MongoDB Atlas for production, and then host everything else (frontend and express part of backend) on something else? Thanks!

  • @felixosei403
    @felixosei403 Жыл бұрын

    To those now trying out this, the Mongoose v7 allows for strict connection to db. A simple way around this is by setting mongoose.set(): mongoose.set('strictQuery',false); mongoose.connect("mongodb uri") .then(() => { ................... }) .catch(() => { ....................... } ) This helped me avoid errors. Hope this helps

  • @ilan117
    @ilan1172 жыл бұрын

    Hi Shaun … are you able to say when will you be adding the user model so we can save a workout per user I guess using the objectID ? I am really looking forward to that 🤲

  • @mohamedyoussef8835
    @mohamedyoussef8835 Жыл бұрын

    Awesome video ++++++++++++++++++ 🙂

  • @daniealkenji7322
    @daniealkenji732211 ай бұрын

    thank you Net Ninja! -from a student from a third world country

  • @doniaelfouly4142
    @doniaelfouly4142 Жыл бұрын

    thanks

  • @muhammadbilalmalik7292
    @muhammadbilalmalik7292 Жыл бұрын

    Net ninja please tell vue.js vs angular what should be choosen only one between these two to learn!!

  • @ghofranedarragi5601
    @ghofranedarragi5601 Жыл бұрын

    you make things '' easy peasy lemon squeezy ''

  • @mgr1282
    @mgr12822 жыл бұрын

    Thanks sensei. PLZ consider Prisma.

  • @trcsports7788
    @trcsports77887 ай бұрын

    Hi, I'm running through your tutorials. I'm getting the following error. Any ideas of what to do? I believe I need to change my version of one of the packages but I'm not sure where to go from there. (node:38660) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) MongoServerError: bad auth : authentication failed

  • @davidhusted817
    @davidhusted817 Жыл бұрын

    Thanks sir i have a problem when create any name for cluster i get "this project has already another free cluster

  • @deepkodes4434
    @deepkodes443410 ай бұрын

    can u tell me how to use local mongodb as well, as that is what we need to do in projects

  • @MuhammadRizky-ub3oy
    @MuhammadRizky-ub3oy2 жыл бұрын

    i love u so much

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thanks Muhammad :)

  • @isaacqadri
    @isaacqadri2 жыл бұрын

    ❤️❤️💕👍🏻

  • @knowlegeurdu8983
    @knowlegeurdu8983 Жыл бұрын

    Sir I face an issue whenever I start the server, I get warning to add mongoose.set('strictQuery', true);

  • @user-ch2ge9hy4j
    @user-ch2ge9hy4j2 жыл бұрын

    MongooseServerSelectionError: unable to get local issuer certificate at Connection.openUri i have this err when trying to connect to mongodb can you help me?

  • @user-ch2ge9hy4j

    @user-ch2ge9hy4j

    Жыл бұрын

    I found the solution The problem was the new node version Just use the recommended version of node

  • @anonymousghost5384
    @anonymousghost53842 жыл бұрын

    Awesome What about nestJs

  • @qwertzuiop1978
    @qwertzuiop19782 ай бұрын

    Question: Does anybody know can we use mongoDB Atlas free tier (sandbox cluster that ninja showed us) for commercial purposes? I am planning on making a startup and all I would need is save the appointment data on some cloud.

  • @CodingSnippetsByWebJoni
    @CodingSnippetsByWebJoni Жыл бұрын

    I am getting an error when try to connect to mongodb. When I run the server it gives etimeout error in console..my internet is fine and have installed latest version of node js but getting this etimeout error.. Kindly help..thanks

  • @MikeMcAllister215
    @MikeMcAllister215 Жыл бұрын

    I had tio get hte 6.8.0 of mongoose to get this working

  • @101kawsar
    @101kawsar2 жыл бұрын

    I would request you to do some Python, like Django or Flask or FastAPI. Would be really cool if you do Mongodb with Flask or FastAPI :)

  • @taofeekiyanda3050

    @taofeekiyanda3050

    2 жыл бұрын

    He has Playlist for Django. Check his channel

  • @101kawsar

    @101kawsar

    2 жыл бұрын

    @@taofeekiyanda3050 that playlist is old and I know Django. I just wanted to see something outside Js world, because nowadays his all contents are Js related.

  • @yusha790
    @yusha7902 жыл бұрын

    Can we see later mevn stack please ?

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    I will do this at some point soon too :)

  • @HadesTimer
    @HadesTimer2 жыл бұрын

    So I'm getting this error every time I try to run your built code: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string. I thought it was something I did wrong in coding so I built the code on your GitHub and I still got it. I've checked my .env file multiple times and it seems to be right.

  • @nirajs.golhar7609

    @nirajs.golhar7609

    2 жыл бұрын

    Things you can check to make this work - 1) make sure you have the string entered in your first parameter so that you can directly enter the URI at the first parameter and not use .env file. 2)run the command and npm install mongoose or npm install if you have cloned repo from Github 3) make sure you enter the correct username and password from the mongoose DB (check your mongoose atlas DB)

  • @HadesTimer

    @HadesTimer

    2 жыл бұрын

    @@nirajs.golhar7609 Thanks. I went over it all again. Honestly I don't know what I did but it finally worked. I wish I knew what was wrong. I think it had something to do with either the password or the code I that I copied into the "MONGO_URI=" line. Took me more than an two hours to solve. I can't believe a simple copy/paste error could be that much of a problem. Well, I just hope it doesn't happen again. Just for the future, does this have to do with me not knowing Javascript well enough or me not know MongoDB well enough? Because I really felt lost debugging this.

  • @user-ch2ge9hy4j

    @user-ch2ge9hy4j

    2 жыл бұрын

    @@HadesTimer wait i have the same problem what to do????

  • @ryany4030

    @ryany4030

    2 жыл бұрын

    @@HadesTimer your password contains special characters like ('@').

  • @khaledalshishani3369

    @khaledalshishani3369

    Жыл бұрын

    @@user-ch2ge9hy4j Hi, make sure your .env file is inside the backend folder

  • @batuhanbatuhan4131
    @batuhanbatuhan4131 Жыл бұрын

    now we have many players they all throw errors to god knows where and we access to those errors by saying catch I assume there is like a global object on the background and we use its catch method. and I guess curly braces are creating a nested hierarchy to catch the error or it may be completely different I am just speculating because these are all new to me and honestly I do not like dealing with errors I dont like try catch it confuses md

  • @trexon2360
    @trexon236010 ай бұрын

    mongose doesnt recognize the connect method

  • @SaiBaba-zi5my
    @SaiBaba-zi5my5 ай бұрын

    I am note getting any errors, but the MongoDB is not getting connected and the collection is not getting created. Can anybody help??

  • @Jane-cq9ku

    @Jane-cq9ku

    5 ай бұрын

    did you change with your actual password in MONGO_URI?

  • @SaiBaba-zi5my

    @SaiBaba-zi5my

    5 ай бұрын

    @@Jane-cq9ku Figured it out 👍🏼

  • @WEBDEVIndo
    @WEBDEVIndo2 жыл бұрын

    Stuck on connecting to mongodb atlas with error: queryTxt ETIMEOUT

  • @guru6031

    @guru6031

    2 жыл бұрын

    Same here..

  • @akishtp

    @akishtp

    2 жыл бұрын

    You guys found any solutions?

  • @WEBDEVIndo

    @WEBDEVIndo

    2 жыл бұрын

    I found solution by using node.js version 2.xx.x instead version 4.1 on connection setup

  • @akishtp

    @akishtp

    2 жыл бұрын

    @@WEBDEVIndoI found that out already, but thanks anyway. It works.

  • @guru6031

    @guru6031

    2 жыл бұрын

    @@WEBDEVIndo thanks bro

  • @carloseduardosanchezcarras4151
    @carloseduardosanchezcarras41515 ай бұрын

    tienes que hacer el video en español brother hahahaha

  • @BilalAhmed-tw5cr
    @BilalAhmed-tw5cr Жыл бұрын

    does any1 mongo site take forever to load 😪😪

  • @sametrise
    @sametrise2 жыл бұрын

    Can you post all parts of the course at a time

  • @Pareshbpatel
    @Pareshbpatel Жыл бұрын

    {2023-02-18}

  • @arney1
    @arney16 ай бұрын

    mongonetworkerror :(

  • @arney1

    @arney1

    6 ай бұрын

    yea my network was just slow af

  • @sayemalmahdi6691
    @sayemalmahdi6691 Жыл бұрын

    Dated on 2 February 2023 For me, I had to write "// connect to db 2 times" and also add "mongoose.set('strictQuery', false);" at the top. I don't know how it works but it works for me !! server.js File: require('dotenv').config() const express = require('express') const mongoose = require('mongoose') mongoose.set('strictQuery', false); const workoutRoutes = require('./routes/workouts') // express app const app = express() // middleware app.use(express.json()) app.use((req, res, next) => { console.log(req.path, req.method) next() }) // routes app.use('/api/workouts', workoutRoutes) // connect to db mongoose.connect(process.env.MONGO_URI) .then(() => { // listen to port app.listen(process.env.PORT, () => { console.log('listening for requests on port', process.env.PORT) }) }) .catch((err) => { console.log(err) }) mongoose.connect(process.env.MONGO_URI) .then(() => { app.listen(process.env.PORT, () => { console.log('listening for requests on port', process.env.PORT) }) }) .catch((err) => { console.log(err) })

  • @Harsh-jh2ql

    @Harsh-jh2ql

    4 күн бұрын

    exactly, it works for me with this method, did you resolve this issue????