Complete MongoDB Tutorial #25 - MongoDB Atlas

Net Ninja · Beginner ·🔧 Backend Engineering ·4y ago

Key Takeaways

This video tutorial covers setting up a MongoDB Atlas cloud database and connecting it to a Node and Express API, demonstrating how to use MongoDB Atlas for a production application.

Full Transcript

all right then my friends so we have made now this node and express api which communicates with mongodb locally on our computer now when it comes to a production application your app won't be communicating with your local mongodb service but instead with a mongodb server online and one way to do that is to use something called mongodb atlas which is a database as a service platform and it allows you to set up a free tier cloud database really easily that you can just then hook up to your application in just a few minutes so the first thing you want to do is head to mongodb forward slash atlas and you want to sign up for a free account or just click on this try free button right here and that's going to ask you to sign up for an account or sign in with google which is what i'm going to do because i already have an account so i'm going to click on that but sign up this way if you prefer and then once you've done that it's eventually going to bring you to your dashboard where you can create databases so it's going to look something like this so i'm going to build a database so let's click on this and then we get three different options now i'm going to go with the shared one which is free right here so click on create and it's going to ask you a few options so first of all the cloud provider which i'm going to stick with aws for and then the region right here now i'm going to stick with the default but you can change that if you wish if you scroll down you can change the cluster name if you want to as well i'm going to stick with the defaults and just create the cluster now when you do that it's going to take a few minutes to create that and it says that down here but while we do that you can create a username and a password and that's going to be used to connect to your database from the code now i've already created a username and password and i'll show you that if i go to database access over here you can see i've got two users and i'm going to use this one right here yoshi and i already created a password which was test123 so you can add that username by filling in those form fields a minute ago and then clicking add or you can go to database access and you could add a new database user right here and you can create it here okay so you need to do that also you need to go to network access and you need to allow access to the database from our computer basically or some other network so i'm going to add ip address and then i'm just going to say allow access from anywhere now you can add your current ip address if you want to which will give you access from your computer i'm going to allow access from anywhere for now but make sure that when you go into production that you don't allow access from anywhere otherwise anyone can access the database and do what they want with it so let's not do that in production let's just do this for testing so i'm going to confirm this and that's just going to take a second as well and then if you go back to database then it probably won't have been created just yet so just hang fire for a couple more minutes all right then so when it's created we can click on this connect button right here to get our connection string so we want to connect our application so click on this and you can see this is the connection string right here the only thing we need to do is replace this with our username that we created and this with the password so i'm going to copy this right here and head back to my code all right then so now back inside the db file all we need to do is replace this connection string right here with the one we just copied so let's delete this and paste in this other one now because this is quite long what i'm going to do is create a new variable up here called uri and i'm going to set that equal to this string like so and then i can just pop the uri variable in here and that looks a bit better so that's all we need to do in our code except we need to also add the username and password right here so i'm going to use yoshi which was the username i created and the password was test1234 and by the way don't try connecting to mine because by the time you watch this tutorial this is not going to exist all right so i'm going to save that now and now we're going to try making requests to this database from postman okay then so in postman we don't actually have to change any of these requests because we're still making requests to localhost which is where our node api is running it's just that in our node api now we're communicating with the mongodb atlas instead of a local installation of mongodb however if i do try to make a request to get all books then obviously we won't get any back because we don't have any books stored inside the mongodb database online however we can't create them so let's open up a post request that we had saved before and if we go to the body we already have all of this book data that we used last time so i'm going to make a post request to add this book so let me send this and see if we get a response and we can see now we get an inserted id and acknowledged is true so hopefully fingers crossed this has worked if i go to this request now to get all the books hopefully we should see that one book come back which we do so that has worked now what i'm going to do is add another book over here i'm just going to change this to the way of kings i'll keep all the rest the same just for simplicity i'm going to click send and we can see that's been added as well and now if we try to get all books again this time hopefully we'll see two books the first one and the second one awesome and also in atlas if you go to browse collections you're now hopefully going to see a new collection called books you can see this right here and down here we can see the two documents so that has all worked so then now we have our database up and running online with mongodb atlas and that was really really simple to do and that my friends is unfortunately the end of this mongodb series now in the future i will also be making a mirn application playlist to show you how to create a full stack application with mongodb node express and react and maybe i might even do a few tutorials about mongodb realm which is a feature-rich development platform for building mobile web and desktop applications and it includes services like authentication serverless functions a database and real-time data synchronization so definitely stay tuned for that so my friends i really really hope you enjoyed this series and you learned something along the way if you did please please please don't forget to share subscribe and like that really means a lot and if you want to access all of my youtube courses without adverts also get access to premium courses and early access courses as well you can do at netninja.dev you can sign up for net ninja pro which is just nine dollars a month and also half price for the first month with this promo code right here and for that like i said you get access to every course without adverts without youtube adverts you also get access to exclusive courses not found anywhere else you get access to my premium courses on udemy and also early access to all of my youtube courses as well so the link to this page to sign up is going to be down below again i really hope you enjoyed this series and i'm going to see you in the very next one [Music] you

Original Description

Hey gang, in this mongodb tutorial you'll learn how to use MongoDB Atlas, a Cloud Database service which allows you to easily set up a hosted database online. 🐱‍💻 View this course & other premium courses without ads on the Net Ninja Pro site: https://net-ninja-pro.teachable.com/p/net-ninja-pro/ 🐱‍💻 Access the course files on GitHub: https://github.com/iamshaunjp/complete-mongodb (lesson code available from lesson 15 onwards) 🐱‍💻 Modern JavaScript Course: On Net Ninja Pro - https://netninja.dev/p/modern-javascript-from-novice-to-ninja On Udemy - https://www.thenetninja.co.uk/udemy/modern-javascript On YouTube - https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc 🐱‍💻 Node.js Crash Course: On Net Ninja Pro - https://netninja.dev/p/node-js-crash-course On YouTube - https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp 🐱‍💻 VS Code - https://code.visualstudio.com/ 🐱‍💻 Download MongoDB - https://www.mongodb.com/try/download/community
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

This video tutorial teaches how to set up a MongoDB Atlas cloud database and connect it to a Node and Express API, allowing users to easily set up a hosted database online for production applications.

Key Takeaways
  1. Sign up for a MongoDB Atlas account
  2. Create a new cluster
  3. Set up network access
  4. Create a username and password
  5. Get the connection string
  6. Connect the Node and Express API to the MongoDB Atlas database
  7. Test the connection using Postman
💡 MongoDB Atlas provides a free tier cloud database that can be easily set up and connected to a Node and Express API, making it a convenient option for production applications.

Related Reads

Up next
Indian Express Editorial Analysis by Chandan Sharma - 1 JULY 2026 | UPSC Current Affairs 2026
StudyIQ IAS
Watch →