Skip to content

Commit 7a413c4

Browse files
author
Sam Vitare
authored
Update part4c.md
Added filenames to be more clear as to which file is involved as per the code explained.
1 parent b8cfdfb commit 7a413c4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/content/4/en/part4c.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const usersRouter = require('./controllers/users')
214214
app.use('/api/users', usersRouter)
215215
```
216216

217-
The contents of the file that defines the router are as follows:
217+
The contents of the file, <i>controllers/users.js</i>, that defines the router are as follows:
218218

219219
```js
220220
const bcrypt = require('bcrypt')
@@ -350,7 +350,7 @@ Mongoose does not have a built-in validator for checking the uniqueness of a fie
350350
npm install mongoose-unique-validator
351351
```
352352

353-
and extend the code by following the library documentation:
353+
and extend the code by following the library documentation in <i>models/user.js</i>:
354354

355355
```js
356356
const mongoose = require('mongoose')
@@ -411,7 +411,7 @@ You can find the code for our current application in its entirety in the <i>part
411411

412412
The code for creating a new note has to be updated so that the note is assigned to the user who created it.
413413

414-
Let's expand our current implementation so that the information about the user who created a note is sent in the <i>userId</i> field of the request body:
414+
Let's expand our current implementation in <i>controllers/notes.js</i> so that the information about the user who created a note is sent in the <i>userId</i> field of the request body:
415415

416416
```js
417417
const User = require('../models/user') //highlight-line
@@ -486,7 +486,7 @@ We would like our API to work in such a way, that when an HTTP GET request is ma
486486

487487
As previously mentioned, document databases do not properly support join queries between collections, but the Mongoose library can do some of these joins for us. Mongoose accomplishes the join by doing multiple queries, which is different from join queries in relational databases which are <i>transactional</i>, meaning that the state of the database does not change during the time that the query is made. With join queries in Mongoose, nothing can guarantee that the state between the collections being joined is consistent, meaning that if we make a query that joins the user and notes collections, the state of the collections may change during the query.
488488

489-
The Mongoose join is done with the [populate](http://mongoosejs.com/docs/populate.html) method. Let's update the route that returns all users first:
489+
The Mongoose join is done with the [populate](http://mongoosejs.com/docs/populate.html) method. Let's update the route that returns all users first in <i>controllers/users.js</i>:
490490

491491
```js
492492
usersRouter.get('/', async (request, response) => {
@@ -520,7 +520,7 @@ The result is now exactly like we want it to be:
520520

521521
![combined data showing no repetition](../../images/4/14new.png)
522522

523-
Let's also add a suitable population of user information to notes:
523+
Let's also add a suitable population of user information to notes in <i>controllers/notes.js</i>:
524524

525525
```js
526526
notesRouter.get('/', async (request, response) => {

0 commit comments

Comments
 (0)