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
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:
218
218
219
219
```js
220
220
constbcrypt=require('bcrypt')
@@ -350,7 +350,7 @@ Mongoose does not have a built-in validator for checking the uniqueness of a fie
350
350
npm install mongoose-unique-validator
351
351
```
352
352
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>:
354
354
355
355
```js
356
356
constmongoose=require('mongoose')
@@ -411,7 +411,7 @@ You can find the code for our current application in its entirety in the <i>part
411
411
412
412
The code for creating a new note has to be updated so that the note is assigned to the user who created it.
413
413
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:
@@ -486,7 +486,7 @@ We would like our API to work in such a way, that when an HTTP GET request is ma
486
486
487
487
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.
488
488
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>:
0 commit comments