You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/3/en/part3c.md
+12-16Lines changed: 12 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,15 +77,11 @@ Read now the chapters on [collections](https://docs.mongodb.com/manual/core/data
77
77
78
78
Naturally, you can install and run MongoDB on your computer. However, the internet is also full of Mongo database services that you can use. Our preferred MongoDB provider in this course will be [MongoDB Atlas](https://www.mongodb.com/atlas/database).
79
79
80
-
Once you've created and logged into your account, let us start by selecting the free option:
81
-
82
-

83
-
84
-
Pick the cloud provider and location and create the cluster:
80
+
Once you've created and logged into your account, let's create a new cluster using the button visible on the front page. From the view that opens, select the free plan, determine the cloud provider and data center, and create the cluster:
85
81
86
82

87
83
88
-
Let's wait for the cluster to be ready for use. This can take some minutes.
84
+
The provider selected is <i>AWS</i> and the region is <i>Stockholm (eu-north-1)</i>. Note that if you choose something else, your database connection string will be slightly different from this example. Wait for the cluster to be ready, which will take a few minutes.
89
85
90
86
**NB** do not continue before the cluster is ready.
91
87
@@ -98,19 +94,19 @@ Next, we have to define the IP addresses that are allowed access to the database
98
94

99
95
100
96
Note: In case the modal menu is different for you, according to MongoDB documentation, adding 0.0.0.0 as an IP allows access from anywhere as well.
101
-
102
-
Finally, we are ready to connect to our database. To do this, we need the database connection string, which can be found by first clicking <i>connect</i> and then choosing <i>Connect to your application</i>:
97
+
98
+
Finally, we are ready to connect to our database. To do this, we need the database connection string, which can be found by selecting <i>Connect</i> and then <i>Drivers</i> from the view, under the <i>Connect to your application</i> section:
The view displays the <i>MongoDB URI</i>, which is the address of the database that we will supply to the MongoDB client library we will add to our application:
To avoid authentication issues with the password variable in index.js, we need to create a .env file by running npm install dotenv in the command line. Then, let's create the .env file in the root of your directory. In that file, you should place your URI:
Don't forget to replace the string with your details.
390
386
Once the .env file is ready, remember to add it to your .gitignore file to prevent pushing the password to Git:
@@ -536,7 +532,7 @@ npm install dotenv
536
532
To use the library, we create a <i>.env</i> file at the root of the project. The environment variables are defined inside of the file, and it can look like this:
Copy file name to clipboardExpand all lines: src/content/3/fi/osa3c.md
+9-13Lines changed: 9 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,15 +77,11 @@ Lue nyt linkitetty [johdanto](https://github.com/fullstack-hy2020/misc/blob/mast
77
77
78
78
MongoDB:n voi asentaa paikallisesti omalle koneelle. Internetistä löytyy kuitenkin myös palveluna toimivia Mongoja, joista tämän hetken paras valinta on [MongoDB Atlas](https://www.mongodb.com/atlas/database).
79
79
80
-
Kun käyttäjätili on luotu ja kirjauduttu, Aloitetaan valitsemalla kokeiluihin sopiva ilmainen vaihtoehto
81
-
82
-

83
-
84
-
Valitaan sopiva pilvipalvelu ja konesali, ja luodaan klusteri:
80
+
Kun käyttäjätili on luotu ja kirjauduttu, luodaan käyttöömme uusi klusteri etusivulla näkyvästä painikkeesta. Avautuvasta näkymästä valitaan kokeiluihin sopiva ilmainen vaihtoehto sekä pilvipalvelu ja konesali, ja luodaan klusteri:
85
81
86
82

87
83
88
-
Odotetaan että klusteri on valmiina, mihin menee noin useita minuutteja.
84
+
Provideriksi on valittu _AWS_ ja Regioniksi _Stockholm (eu-north-1)_. Huomaa, että jos valitset näihin jotakin muuta, tulee tietokannan yhteysosoitteesi olemaan hieman erilainen kuin tässä esimerkissä. Odotetaan että klusteri on valmiina, mihin menee joitakin minuutteja.
89
85
90
86
**HUOM:** Älä jatka eteenpäin ennen kun klusteri on valmis!
91
87
@@ -97,7 +93,7 @@ Seuraavaksi tulee määritellä ne IP-osoitteet, joista tietokantaan pääsee k
97
93
98
94

99
95
100
-
Lopulta ollaan valmiina ottamaan tietokantayhteys. Yhteyden muodostamiseksi tarvitsemme tietokannan yhteysosoitteen, joka löytyy esimerkiksi valitsemalla <i>connect</i> ja sen jälkeisestä näkymästä <i>connect your application</i>:
96
+
Lopulta ollaan valmiina ottamaan tietokantayhteys. Yhteyden muodostamiseksi tarvitaan tietokannan yhteysosoite, joka löytyy esimerkiksi valitsemalla <i>connect</i> ja sen jälkeisestä näkymästä <i>Connect your application</i>-osiosta kohta <i>Drivers</i>:
Sovelluksen juurihakemistoon tehdään sitten tiedosto nimeltään <i>.env</i>, jonne tarvittavien ympäristömuuttujien arvot määritellään. Tiedosto näyttää seuraavalta:
@@ -548,7 +544,7 @@ Koska Fly.io ei hyödynnä gitiä, menee myös .env-tiedosto Fly.io:n palvelimel
548
544
ja asettaa ympäristömuuttujan arvo komennolla:
549
545
550
546
```
551
-
fly secrets set MONGODB_URI='mongodb+srv://fullstack:[email protected]/noteApp?retryWrites=true&w=majority'
547
+
fly secrets set MONGODB_URI='mongodb+srv://fullstack:[email protected]/noteApp?retryWrites=true&w=majority&appName=Cluster0'
552
548
```
553
549
554
550
Koska .env-tiedosto määrittelee myös ympäristömuuttujan PORT arvon, on .env:in ignorointi oikeastaan välttämätöntä jotta sovellus ei yritä käynnistää itseään väärään portiin.
0 commit comments