diff --git a/files/en-us/learn/server-side/express_nodejs/deployment/index.md b/files/en-us/learn/server-side/express_nodejs/deployment/index.md index 7de93dc9f5bd279..f1f550fd94a6362 100644 --- a/files/en-us/learn/server-side/express_nodejs/deployment/index.md +++ b/files/en-us/learn/server-side/express_nodejs/deployment/index.md @@ -118,7 +118,7 @@ It will look something like this: ```js const mongoDB = - "mongodb+srv://your_user_name:your_password@cluster0.lz91hw2.mongodb.net/local_library?retryWrites=true&w=majority"; + "mongodb+srv://your_user_name:your_password@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority"; ``` Replace the line with the following code that uses `process.env.MONGODB_URI` to get the connection string from an environment variable named `MONGODB_URI` if has been set (use your own database URL instead of the placeholder below). @@ -129,7 +129,7 @@ const mongoose = require("mongoose"); mongoose.set("strictQuery", false); const dev_db_url = - "mongodb+srv://your_user_name:your_password@cluster0.lz91hw2.mongodb.net/local_library?retryWrites=true&w=majority"; + "mongodb+srv://your_user_name:your_password@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority"; const mongoDB = process.env.MONGODB_URI || dev_db_url; main().catch((err) => console.log(err)); diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/index.md b/files/en-us/learn/server-side/express_nodejs/mongoose/index.md index 5a50b0537552f7e..904dfbd64e19c55 100644 --- a/files/en-us/learn/server-side/express_nodejs/mongoose/index.md +++ b/files/en-us/learn/server-side/express_nodejs/mongoose/index.md @@ -589,28 +589,37 @@ You will first need to [create an account](https://www.mongodb.com/cloud/atlas/r After logging in, you'll be taken to the [home](https://cloud.mongodb.com/v2) screen: 1. Click the **+ Create** button in the _Overview_ section. + ![Create a database on MongoDB Atlas.](mongodb_atlas_-_createdatabase.jpg) -2. This will open the _Deploy your database_ screen. Click on the **M0 FREE** option template. +2. This will open the _Deploy your cluster_ screen. + Click on the **M0 FREE** option template. + ![Choose a deployment option when using MongoDB Atlas.](mongodb_atlas_-_deploy.jpg) 3. Scroll down the page to see the different options you can choose. ![Choose a cloud provider when using MongoDB Atlas.](mongodb_atlas_-_createsharedcluster.jpg) + - You can change the name of your Cluster under _Cluster Name_. + We are keeping it as `Cluster0` for this tutorial. + - Deselect the _Preload sample dataset_ checkbox, as we'll import our own sample data later on - Select any provider and region from the _Provider_ and _Region_ sections. Different regions offer different providers. - - You can change the name of your Cluster under _Cluster Name_. We are naming it `Cluster0` for this tutorial. - Tags are optional. We will not use them here. - - Click the **Create** button (creation of the cluster will take some minutes). + - Click the **Create deployment** button (creation of the cluster will take some minutes). 4. This will open the _Security Quickstart_ section. ![Set up the Access Rules on the Security Quickstart screen on MongoDB Atlas.](mongodb_atlas_-_securityquickstart.jpg) - - Enter a username and password. Remember to copy and store the credentials safely as we will need them later on. Click the **Create User** button. + - Enter a username and password for your application to use to access the database (above we have created a new login "cooluser"). + Remember to copy and store the credentials safely as we will need them later on. + Click the **Create User** button. > [!NOTE] > Avoid using special characters in your MongoDB user password as mongoose may not parse the connection string properly. - - Enter `0.0.0.0/0` in the IP Address field. This tells MongoDB that we want to allow access from anywhere. Click the **Add Entry** button. + - Select **Add by current IP address** to allow access from your current computer + - Enter `0.0.0.0/0` in the IP Address field and then click the **Add Entry** button. + This tells MongoDB that we want to allow access from anywhere. > [!NOTE] > It is a best practice to limit the IP addresses that can connect to your database and other resources. Here we allow a connection from anywhere because we don't know where the request will come from after deployment. @@ -640,25 +649,24 @@ After logging in, you'll be taken to the [home](https://cloud.mongodb.com/v2) sc - Click the _Overview_ tab to return to the cluster overview. 10. From the Cluster0 _Overview_ screen click the **Connect** button. + ![Configure connection after setting up a cluster in MongoDB Atlas.](mongodb_atlas_-_connectbutton.jpg) -11. This will open the _Connect to Cluster_ screen. - Click the **Drivers** option under the _Connect to your application_ section. - ![Choose a connection type when connecting with MongoDB Atlas.](mongodb_atlas_-_chooseaconnectionmethod.jpg) +11. This will open the _Connect to Cluster0_ screen. -12. You will now be shown the _Connect_ screen. ![Choose the Short SRV connection when setting up a connection on MongoDB Atlas.](mongodb_atlas_-_connectforshortsrv.jpg) - - Select the Node driver and version as shown. - - **DO NOT** follow the step 2. + - Select your database user. + - Select the _Drivers_ category, then the _Driver_ **Node.js** and _Version_ as shown. + - **DO NOT** install the driver as suggested. - Click the **Copy** icon to copy the connection string. - Paste this in your local text editor. - - Update the username and password with your user's password. + - Replace `` placeholder in the connection string with your user's password. - Insert the database name "local_library" in the path before the options (`...mongodb.net/local_library?retryWrites...`) - Save the file containing this string somewhere safe. You have now created the database, and have a URL (with username and password) that can be used to access it. -This will look something like: `mongodb+srv://your_user_name:your_password@cluster0.lz91hw2.mongodb.net/local_library?retryWrites=true&w=majority` +This will look something like: `mongodb+srv://your_user_name:your_password@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority&appName=Cluster0` ## Install Mongoose @@ -826,7 +834,7 @@ The new things we show here are the field options: Everything else should be familiar from our previous schema. -### Genre model - challenge! +### Genre model - challenge Open your **./models/genre.js** file and create a schema for storing genres (the category of book, e.g. whether it is fiction or non-fiction, romance or military history, etc.). diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_accessrules.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_accessrules.jpg index fcc3363de9d3f1e..46ce3928410568a 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_accessrules.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_accessrules.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_adddata.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_adddata.jpg index 06485913759aaa0..8c9b82aea75c6a8 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_adddata.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_adddata.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_chooseaconnectionmethod.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_chooseaconnectionmethod.jpg deleted file mode 100644 index 62cf5f07d332df6..000000000000000 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_chooseaconnectionmethod.jpg and /dev/null differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectbutton.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectbutton.jpg index 3b83c272a2f19e7..6d742bfc3e37455 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectbutton.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectbutton.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectforshortsrv.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectforshortsrv.jpg index 74dbdca51bd4690..646f8031d6b29c1 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectforshortsrv.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_connectforshortsrv.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createdatabase.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createdatabase.jpg index 64f4f07ec7408d3..74df31cbc9bd360 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createdatabase.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createdatabase.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createsharedcluster.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createsharedcluster.jpg index 3fb6a3e222c8132..47d704c5b245f18 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createsharedcluster.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_createsharedcluster.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_databasecreated.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_databasecreated.jpg index ded166e557178d2..f35961547acafed 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_databasecreated.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_databasecreated.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_deploy.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_deploy.jpg index f427c321d8fad3e..b7b551436b8e18a 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_deploy.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_deploy.jpg differ diff --git a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_securityquickstart.jpg b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_securityquickstart.jpg index 27a1e948dea5f8e..b352043de300396 100644 Binary files a/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_securityquickstart.jpg and b/files/en-us/learn/server-side/express_nodejs/mongoose/mongodb_atlas_-_securityquickstart.jpg differ