Skip to content

Commit d9f3069

Browse files
committed
VK feedback
1 parent 19e4b10 commit d9f3069

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

source/integrations/mongoose-get-started.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ In this tutorial, you will perform the following actions:
176176
:language: javascript
177177
:dedent:
178178

179-
This schema enables a ``timestamps`` option, which adds Mongoose-manged
179+
This schema enables a ``timestamps`` option, which adds mongoose-manged
180180
``createdAt`` and ``updatedAt`` fields to the schema that are updated
181181
automatically. For more information, see the `Timestamps
182182
<https://mongoosejs.com/docs/timestamps.html>`__ page in the Mongoose
@@ -685,9 +685,14 @@ query with the ``where()`` method:
685685
const blogFind = await Blog.findOne({ author: "Jess Garcia" });
686686
console.log(blogFind);
687687

688-
const blogWhere = await Blog.where("author").equals("Jess Garcia");
688+
const blogWhere = await Blog.findOne().where("author").equals("Jess Garcia");
689689
console.log(blogWhere);
690690

691+
In this implementation, the ``where()`` implementation starts with a
692+
``findOne()`` which tells Mongoose to treat it as a ``findOne()`` query. This is
693+
important because if you use ``where()`` on its own (``Blog.where(...)``),
694+
Mongoose implicitly treats it as a ``find()`` operation.
695+
691696
Generally, the ``where()`` method is used for complex queries involving dynamic
692697
query building or multiple comparators, or when using this method improves
693698
readability. There is no performance difference between using the
@@ -698,7 +703,7 @@ after your query, as shown in the following example:
698703

699704
.. code-block:: javascript
700705

701-
const blog = await Blog.where("author").equals("Jess Garcia").select("title author");
706+
const blog = await Blog.findOne().where("author").equals("Jess Garcia").select("title author");
702707
console.log(blog);
703708

704709
For more information, see the following sections of the Mongoose API

0 commit comments

Comments
 (0)