Skip to content

Commit 4129b7d

Browse files
committed
edits
1 parent 1d1dd8a commit 4129b7d

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

source/integrations/mongoose-get-started.txt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ and install the necessary dependencies:
116116

117117
Open your project in your preferred code editor. This tutorial uses ES Modules
118118
instead of CommonJS. You must add the ``module`` type to use ES Modules. Go to
119-
the package.json file and add the following code:
119+
the ``package.json`` file and add the following code:
120120

121121
.. code-block:: json
122122

@@ -159,7 +159,7 @@ folder/file. Open this file and add the following code:
159159
:dedent:
160160

161161
You now have your first model and schema set up, and you can start inserting
162-
data in the database.
162+
data into the database.
163163

164164
Insert Data
165165
-----------
@@ -249,11 +249,11 @@ Find Data
249249
---------
250250

251251
To update a specific document, you can use the Mongoose ``findById()`` method to get
252-
a document by its ObjectId.
252+
a document by its ``ObjectId``.
253253

254254
Add following code to your ``index.js`` file to find a specific article by its
255-
ObjectId, replacing the ``<object id>`` placeholder with the ObjectId for the
256-
document that you inserted previously:
255+
``ObjectId``, replacing the ``<object id>`` placeholder with the ``ObjectId``
256+
value for the document that you inserted previously:
257257

258258
.. io-code-block::
259259
:copyable:
@@ -291,8 +291,8 @@ Like with the {+driver-short+}, you can use Mongoose to project only the fields
291291
you need. The following code specifies to only project the ``title``, ``slug``, and
292292
``content`` fields.
293293

294-
Add the following code to your ``index.js`` file, replacing the
295-
``<object id>`` placeholder with the ObjectId for the document that you inserted
294+
Add the following code to your ``index.js`` file, replacing the ``<object id>``
295+
placeholder with the ``ObjectId`` value for the document that you inserted
296296
previously:
297297

298298
.. io-code-block::
@@ -354,6 +354,8 @@ To delete multiple articles, you can add the following code:
354354

355355
Deleted Many Blogs: { acknowledged: true, deletedCount: 4 }
356356

357+
.. _node-mongoose-get-started-additional-methods:
358+
357359
Additional Methods
358360
------------------
359361

@@ -365,7 +367,7 @@ helpful to reference when getting started with Mongoose.
365367
exists()
366368
~~~~~~~~
367369

368-
The ``exists()`` method returns either null or the ObjectId of a document that
370+
The ``exists()`` method returns either null or the ``ObjectId`` of a document that
369371
matches the provided query. The following is an example of matching an article
370372
based on the ``author`` field:
371373

@@ -384,9 +386,10 @@ operation using ``findOne()`` and the equivalent approach using the ``where()``
384386
.. code-block:: javascript
385387

386388
const blogFind = await Blog.findOne({ author: "Jess Garcia" });
389+
console.log(blogFind);
387390

388391
const blogWhere = await Blog.where("author").equals("Jess Garcia");
389-
console.log(blogWhere)
392+
console.log(blogWhere);
390393

391394
You can use either method to perform find operations. You can also chain
392395
multiple ``where()`` methods to build increasingly complex queries.
@@ -396,8 +399,8 @@ after your query, as shown in the following example:
396399

397400
.. code-block:: javascript
398401

399-
const blog = await Blog.where("author").equals("Jess Garcia").select("title author")
400-
console.log(blog)
402+
const blog = await Blog.where("author").equals("Jess Garcia").select("title author");
403+
console.log(blog);
401404

402405

403406
Validate Your Data
@@ -449,7 +452,7 @@ Now that you have validation on your blog schema, and the author field is
449452
``required``, you must update ``index.js`` to include the author. To do this,
450453
you can create a separate schema.
451454

452-
In the model folder, create a new file named ``User.js``. Add the following code to
455+
In the ``model`` folder, create a new file named ``User.js``. Add the following code to
453456
this file:
454457

455458
.. literalinclude:: /includes/integrations/mongoose-userSchema.js
@@ -627,9 +630,9 @@ Resources and Next Steps
627630
------------------------
628631

629632
You now have a sample project that uses Mongoose to perform CRUD operations on a
630-
MongoDB collection. From here, you can choose to build on this project to include
631-
more complex queries, or you can use this project as a reference for your own
632-
applications.
633+
MongoDB collection. From here, you can choose to build on this project to
634+
incorporate more :ref:`Mongoose methods
635+
<node-mongoose-get-started-additional-methods>` and build more complex queries.
633636

634637
To learn more about using Mongoose with MongoDB, see the `Mongoose documentation
635638
<https://mongoosejs.com/docs/guide.html>`__.

0 commit comments

Comments
 (0)