Skip to content

Commit 194203b

Browse files
committed
use mongoose version 6.12
1 parent dcc3c22 commit 194203b

File tree

6 files changed

+53
-7
lines changed

6 files changed

+53
-7
lines changed

src/content/3/en/part3c.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ We could use the database directly from our JavaScript code with the [official M
121121

122122
Mongoose could be described as an <i>object document mapper</i> (ODM), and saving JavaScript objects as Mongo documents is straightforward with this library.
123123

124-
Let's install Mongoose in our notes project backend:
124+
Let's install Mongoose (version 6.12.2) in our notes project backend:
125125

126126
```bash
127-
npm install mongoose
127+
npm install mongoose@6.12.2
128128
```
129129

130+
At the moment we need to use a bit older version of Mongoose since the most recent (version 8.0) is not supported by a library that we will be using during the course.
131+
130132
Let's not add any code dealing with Mongo to our backend just yet. Instead, let's make a practice application by creating a new file, <i>mongo.js</i> in the root of the notes backend application:
131133

132134
```js
@@ -282,6 +284,14 @@ Note.find({ important: true }).then(result => {
282284

283285
### Exercise 3.12.
284286

287+
**Note** You should install Mongoose version 6.12.2 with the command
288+
289+
```bash
290+
npm install [email protected]
291+
```
292+
293+
since the most recent Mongoose version does not support a library that we will be using in a later part of the course!
294+
285295
#### 3.12: Command-line database
286296

287297
Create a cloud-based MongoDB database for the phonebook application with MongoDB Atlas.

src/content/3/fi/osa3c.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,14 @@ Voisimme käyttää kantaa JavaScript-koodista suoraan Mongon virallisen [MongoD
117117

118118
Mongoosesta voisi käyttää luonnehdintaa <i>object document mapper</i> (ODM), ja sen avulla JavaScript-olioiden tallettaminen MongoDB:n dokumenteiksi on suoraviivaista.
119119

120-
Asennetaan Mongoose:
120+
Asennetaan Mongoosen versio 6.12.2:
121121

122122
```bash
123-
npm install mongoose
123+
npm install mongoose@6.12.2
124124
```
125125

126+
Joudumme käyttämään hieman vanhempaa versiota uusin Mongoose-versio (8.0) ei tue kirjastoa, jota tulemme käyttämään kurssin myöhemmässä osassa!
127+
126128
Ei lisätä MongoDB:tä käsittelevää koodia heti backendin koodin sekaan, vaan tehdään erillinen kokeilusovellus tiedostoon <i>mongo.js</i>:
127129

128130
```js
@@ -274,6 +276,14 @@ Note.find({ important: true }).then(result => {
274276

275277
### Tehtävä 3.12
276278

279+
**HUOM** Asenna Mongoosesta versio 6.12.2 komennolla
280+
281+
```bash
282+
npm install [email protected]
283+
```
284+
285+
Joudumme käyttämään hieman vanhempaa versiota uusin Mongoose-versio ei tue kirjastoa, jota tulemme käyttämään kurssin myöhemmässä osassa!
286+
277287
#### 3.12: tietokanta komentoriviltä
278288

279289
Luo puhelinluettelosovellukselle pilvessä oleva MongoDB-tietokanta Mongo DB Atlaksen avulla.

src/content/4/en/part4a.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,14 @@ The nature of VS code bleeding into how you write your code is probably not idea
409409
410410
In the exercises for this part, we will be building a <i>blog list application</i>, that allows users to save information about interesting blogs they have stumbled across on the internet. For each listed blog we will save the author, title, URL, and amount of upvotes from users of the application.
411411
412+
**Note** You should install Mongoose version 6.12.2 with the command
413+
414+
```bash
415+
npm install mongoose@6.12.2
416+
```
417+
418+
since the most recent Mongoose version does not support a library that we will be using in a later part of the course!
419+
412420
#### 4.1 Blog list, step1
413421
414422
Let's imagine a situation, where you receive an email that contains the following application body:

src/content/4/en/part4c.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,16 @@ userSchema.plugin(uniqueValidator) // highlight-line
379379
// ...
380380
```
381381

382+
Note: when installing the _mongoose-unique-validator_ library, you may encounter the following error message:
383+
384+
![](../../images/4/uniq.png)
385+
386+
The reason for this is that at the time of writing (10.11.2023) the library is not yet compatible with Mongoose version 8. If you encounter this error, you can revert to an older version of Mongoose by running the command
387+
388+
```
389+
npm install [email protected]
390+
```
391+
382392
We could also implement other validations into the user creation. We could check that the username is long enough, that the username only consists of permitted characters, or that the password is strong enough. Implementing these functionalities is left as an optional exercise.
383393

384394
Before we move onward, let's add an initial implementation of a route handler that returns all of the users in the database:

src/content/4/fi/osa4a.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ Eli eksportoitava asia (tässä tilanteessa router-olio) sijoitetaan muuttujaan
397397
398398
Rakennamme tämän osan tehtävissä <i>blogilistasovellusta</i>, jonka avulla käyttäjien on mahdollista tallettaa tietoja Internetistä löytämistään mielenkiintoisista blogeista. Kustakin blogista talletetaan sen kirjoittaja (author), aihe (title), url sekä blogilistasovelluksen käyttäjien antamien äänien määrä.
399399
400+
**HUOM** Asenna Mongoosesta versio 6.12.2 komennolla
401+
402+
```bash
403+
npm install mongoose@6.12.2
404+
```
405+
406+
Joudumme käyttämään hieman vanhempaa versiota uusin Mongoose-versio ei tue kirjastoa, jota tulemme käyttämään kurssin myöhemmässä osassa!
407+
400408
401409
#### 4.1 blogilista, step1
402410

src/content/4/fi/osa4c.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ Huom: asentaessasi kirjastoa _mongoose-unique-validator_ saatat törmätä seura
384384

385385
![](../../images/4/uniq.png)
386386

387-
Syynä tälle on se, että kirjasto ei ole kirjoitushetkellä (13.3.2023) vielä yhteensopiva Mongoosen version 7 kanssa. Jos törmäät virheeseen, voit ottaa käyttöösi Mongoosen vanhemman version suorittamalla komennon
387+
Syynä tälle on se, että kirjasto ei ole kirjoitushetkellä (10.11.2023) vielä yhteensopiva Mongoosen version 8 kanssa. Jos törmäät virheeseen, voit ottaa käyttöösi Mongoosen vanhemman version suorittamalla komennon
388388

389389
```
390-
npm install mongoose@6
390+
npm install mongoose@6.12.2
391391
```
392392

393-
Tämän jälkeen kirjaston _mongoose-unique-validator_ asentaminen onnistuu.
393+
This will install the _mongoose-unique-validator_ library.
394394

395395
Voisimme toteuttaa käyttäjien luomisen yhteyteen myös muita tarkistuksia, esim. onko käyttäjätunnus tarpeeksi pitkä, koostuuko se sallituista merkeistä ja onko salasana tarpeeksi hyvä. Jätämme ne kuitenkin vapaaehtoiseksi harjoitustehtäväksi.
396396

0 commit comments

Comments
 (0)