@@ -662,10 +662,22 @@ Cursors
662
662
-------
663
663
664
664
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:
669
681
670
682
.. code-block:: javascript
671
683
@@ -721,15 +733,9 @@ Consider the following behaviors related to cursors:
721
733
override this behavior, you can specify the "noTimeout" :wiki:`wire
722
734
protocol option <Mongo Wire Protocol>` in your query; however, you
723
735
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.
733
739
734
740
- Write operations may interleave during latent access to the cursor.
735
741
This may cause a document to be returned multiple times. To handle
0 commit comments