-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Query cursor 1 #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query cursor 1 #454
Changes from 3 commits
cf4b7e7
061ec08
8d6d2bf
2ff5702
35c1f8b
e77ec8d
467f5c9
4ff79fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -327,11 +327,23 @@ Consider the following examples that illustrate the use of the | |
Cursor | ||
~~~~~~ | ||
|
||
:method:`find() <db.collection.find()>` returns a :term:`cursor`; | ||
however, in the :program:`mongo` shell, the cursor is automatically | ||
iterated up to 20 times to print the documents referenced by the | ||
cursor. To access the documents, you must explicitly handle the | ||
cursor, as in the following example: | ||
The :method:`find() <db.collection.find()>` method returns a | ||
:term:`cursor`; however, in the :program:`mongo` shell, if the result | ||
of the :method:`find() <db.collection.find()>` is not assigned to a | ||
variable, then the cursor is automatically iterated up to 20 times to | ||
print the documents referenced by the cursor, as in the following | ||
example: | ||
|
||
.. code-block:: javascript | ||
|
||
db.bios.find( { _id: 1 } ); | ||
|
||
This operation will iterate the cursor up to 20 times and print the | ||
first 20 documents referenced by the cursor. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iterate and print the first 20 documents collected by the cursor? (collected? returned? the cursor isn't a list of references, so referenced isn't the right word, and we haven't settled on a consistent term here.) |
||
|
||
If the result of the :method:`find() <db.collection.find()>` is | ||
assigned to a variable, you can use the cursor method :method:`next() | ||
<cursor.next()>` to access the documents, as in the following example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you assign a variable to a query.... |
||
|
||
.. code-block:: javascript | ||
|
||
|
@@ -345,9 +357,21 @@ cursor, as in the following example: | |
print (tojson(myName)); | ||
} | ||
|
||
See the :method:`cursor.forEach()`, :method:`cursor.hasNext()`, | ||
:method:`cursor.next()` documentation for more information on cursor | ||
handling. | ||
For more information on cursor handling, see: | ||
|
||
- :method:`cursor.hasNext()` | ||
|
||
- :method:`cursor.next()` | ||
|
||
- :method:`cursor.forEach()` | ||
|
||
- :ref:`cursors <read-operations-cursors>` | ||
|
||
- :ref:`JavaScript cursor methods<js-query-cursor-methods>` | ||
|
||
|
||
Modify Cursor Behavior | ||
`````````````````````` | ||
|
||
In addition to the ``<query>`` and the ``<projection>`` arguments, the | ||
:program:`mongo` shell and the :doc:`drivers </applications/drivers>` | ||
|
@@ -401,6 +425,11 @@ You may chain these cursor methods; however, the :method:`limit() | |
|
||
db.bios.find().limit( 5 ).sort( { name: 1 } ) | ||
|
||
See :ref:`JavaScript cursor methods <js-query-cursor-methods>` and your | ||
:doc:`driver </applications/drivers>` documentation for more | ||
information on cursor methods. See :ref:`read-operations-cursors` for | ||
more information regarding cursors. | ||
|
||
.. _crud-read-findOne: | ||
.. _crud-read-find-one: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/reference/collected/?