MongoDB Basics, CRUD and Node.js Integration

  Рет қаралды 34,708

LearnWebCode

LearnWebCode

Күн бұрын

Join my premium 2024 bootcamp here learnwebcode.teachable.com/p/...
Let's learn how to setup a MongoDB database in the cloud and then connect to it from within our Node.js application code.
0:00 Intro / Context
4:17 Getting Started
13:22 Node.js Integration
20:22 Environment Variables
25:07 CRUD in Node.js
36:30 Ideas for Practice
42:13 Outro
Learn more about MongoDB queries from their official Node documentation: docs.mongodb.com/drivers/node/
My Example Express Code: github.com/LearnWebCode/expre...
My Example Serverless MongoDB Function: gist.github.com/LearnWebCode/...
Playlist for this full series: • Brad's Bootcamp - Free...
Follow me for updates on new episodes:
Instagram: / javaschiff
Twitter: / learnwebcode
Facebook: / brad-schiff-1542576316...
Twitch: / learnwebcode

Пікірлер: 91
@andrewrico8321
@andrewrico8321 3 жыл бұрын
Broo... You are the BEST Instructor EVER!!!!!
@montukun42
@montukun42 3 жыл бұрын
The best instructor i've ever found on youtube. Btw, waiting for Firebase ❤️
@Goorxun-yeer
@Goorxun-yeer Жыл бұрын
I taught over 25 years in schools and colleges. Brad is really great teacher. Comprehensive knowledge, very clear and straight to the point. Could you please include ( MERN Stack: MongoDB, Express, React & Node.js Full Project) in Udemy Brad? Thanks.
@armacaocomercialltda2349
@armacaocomercialltda2349 2 жыл бұрын
I discovered something interesting that you need to know and explore further, perhaps. I'm Brazilian, I'm 70 years old, my English isn't very good and I still have some hearing difficulties. And it's not because of my age! Your speech, diction and the pauses between words make the Google translator perfectly translate from English to Portuguese. It's like reading a book edited in Portuguese. Incredible!! my name is Jorge
@joel-rg8xm
@joel-rg8xm 2 жыл бұрын
Awesome! Just a remark: I edited this line of code due to Connection Error: (added .MongoClient at the end) const mongodb = require('mongodb').MongoClient
@invertturtle7157
@invertturtle7157 2 жыл бұрын
Thank you, i really appreciate this.. i got stuck in that part too.
@pratapreddylakku2323
@pratapreddylakku2323 2 жыл бұрын
Thank you Joel... I got stuck here and wasted at least an hour
@STUPIDYOUTUBE_HIDINGMSGS
@STUPIDYOUTUBE_HIDINGMSGS 3 жыл бұрын
Clear and straight to the point, great tutorial, I've subscribed!
@codingwithkenny6492
@codingwithkenny6492 3 жыл бұрын
You are an amazing teacher, your explanations are short and sweet which really helps me understand the concept even better!
@stevenjin8755
@stevenjin8755 2 жыл бұрын
Very impressive teaching style, clear, consistent, precise, almost mesmerising ! Would be great to see a lesson on relational database (MySQL), as a beginner, I am, like many learners, still not clear when to choose which type of database, eg. when building a ecommerce website that requires Multi tiers filtering function.
@mwaqaspro
@mwaqaspro 3 жыл бұрын
Best ever instructor! Love you, sir!
@sashaikevich
@sashaikevich 3 жыл бұрын
Great series! You cover a lot here and in your udemy course (and I’m a student in 3 of them), but what you’re missing is email integration. I basically have everything I need to create a mini SaaS, but connecting it with a custom domain, and having my netlify app email user notifications and updates from @domain would be really helpful. Hope you’ll make a video on that one day soon :-)
@lailasatriasuhaimi5231
@lailasatriasuhaimi5231 3 жыл бұрын
The best place to learn ... very good content... your voice is very clear ..
@jackepner9984
@jackepner9984 2 жыл бұрын
Came here from the JS course.... the MongoDB setup is outdated, there are now many more options we're presented with not covered in any of your course material or web series. For a first time user of Mongo, this is creating some concern... Figured most of it out, and the one thing I had to go to SO for, this was the thing: mongodb.connect is no longer a valid function as it stands. You must use MongoClient. The easiest way to fix this is to use this with the declaration: const mongodb = require("mongodb").MongoClient. Simply adding that period and MongoClient at the end seems to have fixed it. There are other ways to go about this, but that is by far the simplest fix. Thank you for all your courses, you're the only teacher I've found in coding that is ACTUALLY teaching and not just telling people to watch them code and learn by some sort of magical telepathy that doesn't exist. Like asking a med student to learn how to perform a heart transplant by only watching one and following along with no practical knowledge or experience... would you trust that person to perform surgery on you!?
@Gibdo_
@Gibdo_ 2 жыл бұрын
I had this problem as well and it is fixed now, but another error pops up saying for line 6 "const db = client.db()". The error says "TypeError: Cannot read properties of undefined (reading 'db')". Anyone know how to fix this?
@codingmonkey5399
@codingmonkey5399 2 жыл бұрын
@@Gibdo_ facing same error
@jackepner9984
@jackepner9984 Жыл бұрын
@@Gibdo_ Can't find this in my code... might sound silly, but if I remember correctly, it may solve it simply by changing 'const' to 'let.' It's possible the db variable needs to be reassigned later on.
@MrBioneto
@MrBioneto 3 жыл бұрын
Great tutorial! Thank you!!!
@Pareshbpatel
@Pareshbpatel 2 жыл бұрын
A great tutorial on performing CRUD operations on a Mongo Database. Thanks, Brad {2021-11-29}
@zhasan66
@zhasan66 3 жыл бұрын
Really excellent video tutorial.
@techmathy5764
@techmathy5764 3 жыл бұрын
Eagerly waiting ❤️
@federicoraulmaciasaparicio1339
@federicoraulmaciasaparicio1339 3 жыл бұрын
yeeeah!! New bootcamp episode!!
@nikhil_squats
@nikhil_squats 3 жыл бұрын
please make more such videos really helpful. start making some mini projects with MERN stack
@streamx2
@streamx2 3 жыл бұрын
If you ever thought you were not clever enough to study a subject, just ask Brad to teach it. Can you move into nuclear physics?
@aeterna_victrix
@aeterna_victrix 2 жыл бұрын
Regarding the 'mongodb.connect is not a function' error. You will need to add ".MongoClient" to your mongodb variable like so..... const mongodb = require("mongodb").MongoClient;
@hgsbrodi
@hgsbrodi 2 жыл бұрын
Thanks
@eloielbonnoi
@eloielbonnoi 2 жыл бұрын
Thank you very much!!
@Yeapes
@Yeapes 3 жыл бұрын
Love From Bangladesh Sir
@msvmanikantasrivishnu7788
@msvmanikantasrivishnu7788 3 жыл бұрын
I am here... thank you...
@amy6149
@amy6149 3 жыл бұрын
You're the best instructor anyone can ever have.
@ilvaritoo
@ilvaritoo 3 жыл бұрын
10/10
@shahriarparvezshuvo4760
@shahriarparvezshuvo4760 3 жыл бұрын
I noticed the Dental braces. Hope your are Okay. 🤔 Half way through this video. Already learned a lot. 👏 Thanks for the quality content. 💚
@LearnWebCode
@LearnWebCode 3 жыл бұрын
😂 the braces finally get to come off pretty soon here! Thanks for the support 💚
@iank7340
@iank7340 3 жыл бұрын
Your tutorials are the TRUE zero to hero.. Thanks You!! Also waiting for firebase
@kenansari
@kenansari 3 жыл бұрын
Thank you, Brad. It was a great introduction to MongoDB. I have already enrolled your React.js course and I am really happy. I consider purchasing also a NodeJs course and I think I have to pick your full-stack course? at this point, I wonder that which template are you using for front-end side? ejs, handlebars or pug? Thank you.
@LearnWebCode
@LearnWebCode 3 жыл бұрын
Thanks! We use EJS for the server-side-rendered HTML in the Full-Stack Node.js course. We do also write front-end JS for several features, but we don't use a library like React or Vue, just plain JS.
@cyb3rtooth199
@cyb3rtooth199 2 жыл бұрын
@@LearnWebCode I've actually been following along with the full-stack javascript course and I'm kinda stuck. In the course, you use: the db.collections().insertOne method to create a new document then you use res.json(info.ops[0]) to return the same document that was just inserted. It would seem that the insertOne() method doesn't work that way anymore. I was redirected to use mongoose to do what you did and I'm hoping I succeed. Any feedback would be highly appreciated.
@computerscience1099
@computerscience1099 3 жыл бұрын
waiting for user auth video :)
@whoman7930
@whoman7930 3 жыл бұрын
Please we need in-depth tutorial on firebase! Also, will we create a big project at the end of this bootcamp series, using all the knowledge we've learnt (and will learn) together just like the real world?.
@STUPIDYOUTUBE_HIDINGMSGS
@STUPIDYOUTUBE_HIDINGMSGS 3 жыл бұрын
If you still can't find a good tutorial on Firebase, search Shaun Pelling's YT channel.
@whoman7930
@whoman7930 3 жыл бұрын
@@STUPIDKZfaq_HIDINGMSGS I know firebase, but I need in depth tutorial. An advanced guide sort of. I hv already watched all videos of Ninja on firebase. They are very basic, and doesn’t teach real world project.
@STUPIDYOUTUBE_HIDINGMSGS
@STUPIDYOUTUBE_HIDINGMSGS 3 жыл бұрын
@@whoman7930 Do medium to big companies use Firebase? What sort of real-world application, do you use it in your company?
@whoman7930
@whoman7930 3 жыл бұрын
@@STUPIDKZfaq_HIDINGMSGS nah, Im still learning, I want to use firebase in my project. But I can’t visualize all the different firebase products working together in most efficient way. That what I’m lacking.
@testm4826
@testm4826 2 жыл бұрын
at the newer version you cant use let mongodb = require("mongodb").MongoClient in order to make the connect يا براد يا غالي يا فلاح
@ashkanahmadi
@ashkanahmadi 3 жыл бұрын
Excellent video as usual Brad. I have already finished 2 of your udemy courses and I just purchased 2 more. Looking forward to them. I was wondering if you would consider putting together some PHP/SQL courses and/or a KZfaq series? I know they are not super modern and trendy now like React and MongoDB but do you think in the future you might publish courses related to those topics? Or even React/Angular/Vue ones? Thank you
@LearnWebCode
@LearnWebCode 3 жыл бұрын
Hi, thanks so much! You're right, even if PHP/SQL aren't super trendy, if we look at job boards it's clear they're super in-demand which really is what's most important. Even though in the real world it makes sense to jump right into Laravel or WordPress I do think a PHP/SQL essentials course would be useful. I'd like to cover Vue at some point!
@ashkanahmadi
@ashkanahmadi 3 жыл бұрын
@@LearnWebCode that sounds great. I have already finished the WP course. I will definitely keep an eye on the upcoming videos and courses 👍
@techmathy5764
@techmathy5764 3 жыл бұрын
Please make a video on how to use any API documentation for beginners
@Aloysiusb
@Aloysiusb 3 жыл бұрын
You are the BEST!
@mhmdabubakar98
@mhmdabubakar98 3 жыл бұрын
u r
@FuzzkieMc
@FuzzkieMc Жыл бұрын
Brad offers wonderful instruction. However, in the MongoDB/CRUD video, I get this error: TypeError: mongodb.connect is not a function at Object. (C:\Users\David McMurrey\Desktop\mongodb-node-test\index.js:6:9) I added .MongoClient as indicated by joel-rg below. Now it just hangs. -- david
@md.farukuzzaman3911
@md.farukuzzaman3911 2 жыл бұрын
hey, there is an error message, it says ''' mongodb.connect is not a function
@mahmoudkhalaf4156
@mahmoudkhalaf4156 2 жыл бұрын
I have the same problem
@AlexNicholls.
@AlexNicholls. 3 жыл бұрын
when you get data back from mongodb is that a string? if i console log "results" i get back an object looking response but when try to access one of the items, console log "results.name" for example i get undefined. basically im trying to find out how to access and use items from a mongodb object in node
@AlexNicholls.
@AlexNicholls. 3 жыл бұрын
the answer incase anybody else is wondering is that it is an array of objects, "results[0].name" gives the result i was looking for. probably im the only idiot who took a couple hours to realise that
@bikashgurung3830
@bikashgurung3830 3 жыл бұрын
Brad you're my favourite instructor. Please react..
@LearnWebCode
@LearnWebCode 3 жыл бұрын
Thanks! My reaction: 🙂
@tapankumarbaral1244
@tapankumarbaral1244 3 жыл бұрын
@@LearnWebCode pretty sure he was asking for the react js series 😅😅
@streamx2
@streamx2 3 жыл бұрын
Is the next video coming up tomorrow?
@jayjohnx
@jayjohnx 2 жыл бұрын
mongodb.ObjectId("therespectiveid") gave me an error as mongodb.ObjectId is not a function. to solve it, at the top I had to declare, const ObjectId = require("mongodb").ObjectId
@federicoraulmaciasaparicio1339
@federicoraulmaciasaparicio1339 3 жыл бұрын
Is there a way to join two different collections in Mongodb?
@LearnWebCode
@LearnWebCode 3 жыл бұрын
Yep! Well, it's not exactly the same as in a SQL system, but it's been useful for me, check this documentation page out: docs.mongodb.com/manual/reference/operator/aggregation/lookup/
@rememberkismat
@rememberkismat 2 жыл бұрын
Hello sir, im learning fullstack course from udemy . Your way of teaching is just immaculate for me to learn many things in java script. But during the process, i came across an error "typeerror: mongodb.connect is not a function " . I tried to fix it but still getting same error. Please help if im missing something here......
@eloielbonnoi
@eloielbonnoi 2 жыл бұрын
I'm getting the same error...have you fixed it?
@eloielbonnoi
@eloielbonnoi 2 жыл бұрын
I just found it in the comments. You have to modify this: const mongodb = require("mongodb").MongoClient;
@jackendycherenfant3929
@jackendycherenfant3929 3 жыл бұрын
I have been trying to update some fields of an API for two long weeks and still cannot do it. How to update data from a req.body please (I trying to update data from user or Postman but it returns Null not the updated data), Thank you very much in advance.
@LearnWebCode
@LearnWebCode 3 жыл бұрын
Is it an API that you created, or an existing one with documentation? I don't think it's a technical / coding problem, instead maybe the API is expecting something that you're not passing along to it?
@jackendycherenfant3929
@jackendycherenfant3929 3 жыл бұрын
@@LearnWebCode I created it. thank you. Maybe in the future you can do an express API example? it would me great unfortunately I looked up on google all APIs > crud are created with and done with Mongoose. not with mongodb node driver.
@mahmoudkhalaf4156
@mahmoudkhalaf4156 2 жыл бұрын
TypeError: mongodb.connect is not a function, Does anyone know the solution to this problem?
@inqiatreza6752
@inqiatreza6752 2 жыл бұрын
I'm looking for the answer too. I created class with MongoClient though but now I'm stuck on MongoClient.ObjectId is not a constructor error.
@ebesquin
@ebesquin 3 жыл бұрын
Brad Due to the changes of mongodb V5 the code needs to be updated, it is sending errors. Thank you very much
@LearnWebCode
@LearnWebCode 3 жыл бұрын
Hi, for a different project, just this morning I was testing MongoDB 5.0.1 via Docker and the traditional approaches I use in this video were working, although it was a slightly different project. Are the errors you were getting just related to opening the initial connection? Or on a certain action?
@ebesquin
@ebesquin 2 жыл бұрын
@@LearnWebCode Brad Thank you again, I apologize, but I didn't realize that you answered so long ago. The anouncement you made in udemy course, Learn JavaScript: Full-Stack... on the mid of october "npm install mongodb@3.7.2" solved the isue perfect.
@dimitmoto1716
@dimitmoto1716 2 жыл бұрын
mongodb.ObjectId gives me an error. To fix it I need to write ObjectId instead mongodb.ObjectId and in the beggining of the document to write const {ObjectId} = require("bson")
@18770299
@18770299 2 жыл бұрын
thanks!
@lardosian
@lardosian 3 жыл бұрын
Ye ye ye whatever...now where's the cat?!! Only kidding.
@dogsystem2
@dogsystem2 3 жыл бұрын
in 2021 its saying db is undefined
@paulblack7919
@paulblack7919 2 жыл бұрын
Tried everything why is error.." TypeError: mongodb.ObjectId is not a function" ... when trying deleteOne function ?
@paulblack7919
@paulblack7919 2 жыл бұрын
@Giovanni Adorno Thank you.
@dastgirakhtar9782
@dastgirakhtar9782 3 жыл бұрын
Not working version error still
@LearnWebCode
@LearnWebCode 3 жыл бұрын
What does the error message say?
@dastgirakhtar9782
@dastgirakhtar9782 3 жыл бұрын
@@LearnWebCode async function without a catch block or by rejecting a promise........
@prim_plup
@prim_plup 3 жыл бұрын
@@LearnWebCode Hello, I am also getting the same error.
@SLP1177
@SLP1177 3 жыл бұрын
34:30 How to use ObjectId on mongodb => { _id: mongodb.ObjectId("bbdb3b3bb4bb2bb2bb4bb4bbb") }
@AnonymousAccount514
@AnonymousAccount514 3 жыл бұрын
weird....his voice sounds just like Bucky Roberts....thenewboston
@LearnWebCode
@LearnWebCode 3 жыл бұрын
Haha, did you see he just posted to KZfaq last week for the first time in years? Pretty cool stuff 🥳
@shahriarparvezshuvo4760
@shahriarparvezshuvo4760 3 жыл бұрын
@@LearnWebCode Yeah. I'm amazed by the the cryptocurrency stuffs he was talking about. He really got emotional while explaining his discovery of finding the efficiency algorithms for reducing the delay for transactions. Really exciting stuffs. 🔥
@cd78
@cd78 3 жыл бұрын
Are folks still using node.
@2chikas
@2chikas 3 жыл бұрын
Do you know of any better option?
@GoogleUser-mx5oe
@GoogleUser-mx5oe 3 жыл бұрын
I'm sorry man IDK about those comments, but I didn't like how you just skip some really useful things and how u stop at a useless topic and talk about it for about 2 or 3 minutes ...
@jediampm
@jediampm 3 жыл бұрын
Hi Brad, why teach MongoDB/ NoSQL database when in most (99%) real world ( professional environments) you should know SQL and work with for example MySQL, PostgreSQL, MsSQL or Oracle Databases? for me this video, make no sense and waste of time because one thing is choose between PHP and NodeJS, a complete thing is about databases, that majority of the companies use a SQL Database. ;)
Cookies, Sessions, JSON Web Tokens (JWT) and More 🍪🔐
46:41
LearnWebCode
Рет қаралды 104 М.
Create An API: CORS, SPA / Client-Side Routing Explanation
40:35
LearnWebCode
Рет қаралды 25 М.
Incredible magic 🤯✨
00:53
America's Got Talent
Рет қаралды 81 МЛН
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 50 МЛН
ОСКАР vs БАДАБУМЧИК БОЙ!  УВЕЗЛИ на СКОРОЙ!
13:45
Бадабумчик
Рет қаралды 6 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 36 МЛН
Learn Express.js In 48 Minutes: Web Server Tutorial
47:39
LearnWebCode
Рет қаралды 57 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 463 М.
How To Use TypeScript With Express & Node
17:05
Colt Steele
Рет қаралды 66 М.
JavaScript Callbacks, Promises, and Async / Await Explained
38:54
LearnWebCode
Рет қаралды 40 М.
Programming Is NOT Enough | Add these 7 skills…
13:19
Travis Media
Рет қаралды 415 М.
DHH discusses SQLite (and Stoicism)
54:00
Aaron Francis
Рет қаралды 55 М.
Mongoose Crash Course - Beginner Through Advanced
33:36
Web Dev Simplified
Рет қаралды 454 М.
MongoDB Crash Course 2022
27:22
Traversy Media
Рет қаралды 197 М.
Incredible magic 🤯✨
00:53
America's Got Talent
Рет қаралды 81 МЛН