Skip to content

Commit 8d6d2bf

Browse files
committed
DOCS-799 migrate queries and cursors with tads comments
1 parent 061ec08 commit 8d6d2bf

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed

source/applications/read.txt

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,23 @@ Consider the following examples that illustrate the use of the
327327
Cursor
328328
~~~~~~
329329

330-
:method:`find() <db.collection.find()>` returns a :term:`cursor`;
331-
however, in the :program:`mongo` shell, the cursor is automatically
332-
iterated up to 20 times to print the documents referenced by the
333-
cursor. To access the documents, you must explicitly handle the cursor,
334-
as in the following example:
330+
The :method:`find() <db.collection.find()>` method returns a
331+
:term:`cursor`; however, in the :program:`mongo` shell, if the result
332+
of the :method:`find() <db.collection.find()>` is not assigned to a
333+
variable, then the cursor is automatically iterated up to 20 times to
334+
print the documents referenced by the cursor, as in the following
335+
example:
336+
337+
.. code-block:: javascript
338+
339+
db.bios.find( { _id: 1 } );
340+
341+
This operation will iterate the cursor up to 20 times and print the
342+
first 20 documents referenced by the cursor.
343+
344+
If the result of the :method:`find() <db.collection.find()>` is
345+
assigned to a variable, you can use the cursor method :method:`next()
346+
<cursor.next()>` to access the documents, as in the following example:
335347

336348
.. code-block:: javascript
337349

@@ -353,11 +365,10 @@ For more information on cursor handling, see:
353365

354366
- :method:`cursor.forEach()`
355367

356-
- :ref:`read-operations-cursors`
368+
- :ref:`cursors <read-operations-cursors>`
357369

358-
- :ref:`js-query-cursor-methods`
370+
- :ref:`JavaScript cursor methods<js-query-cursor-methods>`
359371

360-
-
361372

362373
Modify Cursor Behavior
363374
``````````````````````
@@ -416,9 +427,8 @@ You may chain these cursor methods; however, the :method:`limit()
416427

417428
See :ref:`JavaScript cursor methods <js-query-cursor-methods>` and your
418429
:doc:`driver </applications/drivers>` documentation for more
419-
information on cursor methods.
420-
421-
See also :ref:`read-operations-cursor-considerations` for othe
430+
information on cursor methods. See :ref:`read-operations-cursors` for
431+
more information regarding cursors.
422432

423433
.. _crud-read-findOne:
424434
.. _crud-read-find-one:

source/core/read-operations.txt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,22 @@ Cursors
662662
-------
663663

664664
The :method:`find() <db.collection.find()>` method returns a
665-
:term:`cursor`; however, in the :program:`mongo` shell, the cursor is
666-
automatically iterated up to 20 times to print the documents referenced
667-
by the cursor. To access the documents, you must explicitly handle the
668-
cursor:
665+
:term:`cursor`; however, in the :program:`mongo` shell, if the result
666+
of the :method:`find() <db.collection.find()>` is not assigned to a
667+
variable, then the cursor is automatically iterated up to 20 times to
668+
print the documents referenced by the cursor, as in the following
669+
example:
670+
671+
.. code-block:: javascript
672+
673+
db.inventory.find( { type: 'food' } );
674+
675+
This operation will iterate the cursor up to 20 times and print the
676+
first 20 documents referenced by the cursor.
677+
678+
If the result of the :method:`find() <db.collection.find()>` is
679+
assigned to a variable, you can use the cursor method :method:`next()
680+
<cursor.next()>` to access the documents, as in the following example:
669681

670682
.. code-block:: javascript
671683

@@ -721,15 +733,9 @@ Consider the following behaviors related to cursors:
721733
override this behavior, you can specify the "noTimeout" :wiki:`wire
722734
protocol option <Mongo Wire Protocol>` in your query; however, you
723735
should either close the cursor manually or exhaust the cursor. In the
724-
:program:`mongo` shell, you can set the "noTimeout" option (i.e.
725-
hexadecimal ``0x10`` or ``16``) as in the following example:
726-
727-
.. code-block:: javascript
728-
729-
var cursorNoTimeout = db.inventory.find().addOption( 0x10 )
730-
731-
See your :doc:`driver </applications/drivers>` documentation for
732-
information on setting "noTimeout" option.
736+
:program:`mongo` shell, you can set the "noTimeout" option. See your
737+
:doc:`driver </applications/drivers>` documentation for information
738+
on setting the "noTimeout" option.
733739

734740
- Write operations may interleave during latent access to the cursor.
735741
This may cause a document to be returned multiple times. To handle

0 commit comments

Comments
 (0)