@@ -24,9 +24,9 @@ Overview
2424Mongoose is an Object Data Modeling (ODM) library for MongoDB. You can use
2525Mongoose to help with data modeling, schema enforcement, model validation, and
2626general data manipulation. Because MongoDB has a flexible data model that allows
27- you to easily alter and update databases in the future, there aren't rigid
28- schemas. Mongoose enforces a semi-regid schema from the beginning. When you use
29- Mongoose, you must define a schema and model.
27+ you to alter and update databases in the future, there aren't rigid schemas.
28+ Mongoose enforces a semi-regid schema from the beginning. When you use Mongoose,
29+ you must define a schema and model.
3030
3131In this tutorial, you will perform the following actions:
3232
@@ -38,7 +38,7 @@ In this tutorial, you will perform the following actions:
3838- Validate your data
3939- Use multiple schemas and middleware
4040
41- You will also learn other useful methods to grow your experience using Mongoose with MongoDB.
41+ You will also learn additional methods to grow your experience using Mongoose with MongoDB.
4242
4343Schemas
4444-------
@@ -117,7 +117,7 @@ and install the necessary dependencies:
117117 npm i -D nodemon
118118
119119Open your project in your preferred code editor. This tutorial uses ES Modules
120- instead of CommonJS. You need to add the module type to use ES Modules. Go to
120+ instead of CommonJS. You must add the `` module`` type to use ES Modules. Go to
121121the package.json file and add the following code:
122122
123123.. code-block:: json
@@ -361,8 +361,8 @@ Additional Methods
361361
362362Mongoose includes several helper methods that are abstracted from regular
363363MongoDB methods. In this section, you can find examples of some of these
364- methods. You don't need to add these methods to your ``index.js`` file to proceed
365- with the tutorial, but they are helpful to reference .
364+ methods. These methods are not used specifically in this tutorial, but they are
365+ helpful to reference when getting started with Mongoose .
366366
367367exists()
368368~~~~~~~~
@@ -405,11 +405,11 @@ after your query, as shown in the following example:
405405Validate Your Data
406406------------------
407407
408- If you refer to the schema, note that the articles inserted so far have not
409- contained the ``author``, ``dates``, or `` comments`` fields even though these fields are
410- included in the schema. This is because although you defined the structure of
411- your document, you have not defined which fields are required. Without defining
412- the required fields, you can omit any fields.
408+ The articles inserted so far have not contained the ``author``, ``dates``, or
409+ `` comments`` fields, even though these fields are included in the schema. This is
410+ because although you defined the structure of your document, you have not
411+ defined which fields are required. Without defining the required fields, you can
412+ omit any fields.
413413
414414To add data validation and define these requirements, update the schema in
415415``Blog.js`` like the following:
@@ -429,7 +429,7 @@ its value.
429429 ``value: {type: String}``.
430430
431431You can use several validation methods with Mongoose. For example, you can set
432- ``required`` to true on any fields that you would like to require.
432+ ``required`` to true on any fields that you want to require.
433433
434434You can also validate the type and the formatting. In the preceding code, the
435435``slug`` field is defined as a ``string`` that is always in ``lowercase``. This
@@ -448,7 +448,7 @@ Multiple Schemas
448448----------------
449449
450450Now that you have validation on your blog schema, and the author field is
451- ``required``, you need to update ``index.js`` to include the author. To do this,
451+ ``required``, you must update ``index.js`` to include the author. To do this,
452452you can create a separate schema.
453453
454454In the model folder, create a new file named ``User.js``. Add the following code to
@@ -458,8 +458,8 @@ this file:
458458 :language: javascript
459459 :dedent:
460460
461- To reference blog schema, update the ``Blog.js`` file to include the following
462- code:
461+ To reference this new user model in the blog schema, update the ``Blog.js`` file
462+ to include the following code:
463463
464464.. code-block:: javascript
465465
@@ -500,7 +500,7 @@ the following code to the top of the file to import the user model:
500500 :end-before: end-user-import
501501
502502Since you added field validation to the blog schema, the previous code to
503- insert, update, and delete blogs, as well as to specify fields to project, won't
503+ insert, update, and delete blogs, and to specify fields to project, won't
504504pass the validation and the application will error.
505505
506506Replace the existing code with the following code to create a new user, and then
@@ -532,7 +532,7 @@ following code:
532532 __v: 0
533533 }
534534
535- The preceding code adds a ``users`` collection along with the ``blogs`` collection in
535+ The preceding code adds a ``users`` collection with the ``blogs`` collection in
536536the MongoDB database. This code adds the required ``author`` field and sets its
537537value to the ``user._id``.
538538
0 commit comments