Skip to content

Commit f3d0539

Browse files
committed
WRITING-1480: Fix build warning regarding missing cursor documentation
1 parent 59209be commit f3d0539

File tree

7 files changed

+85
-19
lines changed

7 files changed

+85
-19
lines changed

config/redirects.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,20 @@ code: 303
10281028
outputs:
10291029
- 'before-v3.0'
10301030
---
1031+
from: '/reference/method/cursor.noCursorTimeout'
1032+
to: '/reference/method'
1033+
type: 'redirect'
1034+
code: 303
1035+
outputs:
1036+
- 'before-v3.0'
1037+
---
1038+
from: '/reference/method/cursor.close'
1039+
to: '/reference/method'
1040+
type: 'redirect'
1041+
code: 303
1042+
outputs:
1043+
- 'before-v3.0'
1044+
---
10311045
from : '/reference/command/geoWalk'
10321046
to: '/reference/command/nav-geospatial/'
10331047
type: 'redirect'

source/core/cursors.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,19 @@ Closure of Inactive Cursors
4646
~~~~~~~~~~~~~~~~~~~~~~~~~~~
4747

4848
By default, the server will automatically close the cursor after 10
49-
minutes of inactivity or if client has exhausted the cursor. To
50-
override this behavior, you can specify the ``noTimeout`` flag in your
51-
query using :method:`cursor.addOption()`; however, you should either
52-
close the cursor manually or exhaust the cursor. In the
53-
:program:`mongo` shell, you can set the ``noTimeout`` flag:
49+
minutes of inactivity, or if client has exhausted the cursor. To
50+
override this behavior in the :program:`mongo` shell, you can use
51+
the :method:`cursor.noCursorTimeout()` method:
5452

5553
.. code-block:: javascript
5654

57-
var myCursor = db.inventory.find().addOption(DBQuery.Option.noTimeout);
55+
var myCursor = db.inventory.find().noCursorTimeout();
56+
57+
You must either close the cursor manually with :method:`cursor.close()` or
58+
exhaust the cursor.
5859

5960
See your :doc:`driver </applications/drivers>` documentation for
60-
information on setting the ``noTimeout`` flag. For the :program:`mongo`
61-
shell, see :method:`cursor.addOption()` for a complete list of
62-
available cursor flags.
61+
information on setting the ``noCursorTimeout`` flag.
6362

6463
.. _cursor-isolation:
6564

source/includes/ref-toc-method-cursor.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: ":method:`cursor.batchSize()`"
22
file: /reference/method/cursor.batchSize
33
description: "Controls the number of documents MongoDB will return to the client in a single network message."
44
---
5+
name: ":method:`cursor.close()`"
6+
file: /reference/method/cursor.close
7+
description: "Destroy a cursor and free associated server resources."
8+
---
59
name: ":method:`cursor.comment()`"
610
file: /reference/method/cursor.comment
711
description: "Attaches a comment to the query to allow for traceability in the logs and the system.profile collection."
@@ -58,6 +62,10 @@ name: ":method:`cursor.next()`"
5862
file: /reference/method/cursor.next
5963
description: "Returns the next document in a cursor."
6064
---
65+
name: ":method:`cursor.noCursorTimeout()`"
66+
file: /reference/method/cursor.noCursorTimeout
67+
description: "Instructs the server to avoid closing a cursor automatically after a period of inactivity."
68+
---
6169
name: ":method:`cursor.objsLeftInBatch()`"
6270
file: /reference/method/cursor.objsLeftInBatch
6371
description: "Returns the number of documents left in the current cursor batch."
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
==============
2+
cursor.close()
3+
==============
4+
5+
.. default-domain:: mongodb
6+
7+
Definition
8+
----------
9+
10+
.. method:: cursor.close()
11+
12+
Instructs the server to destroy a :ref:`cursor <read-operations-cursors>`
13+
and free associated server resources. The server will automatically close
14+
cursors that have been idle for a period of time or that have no remaining
15+
results.
16+
17+
The :method:`~cursor.close()` method has the following
18+
prototype form:
19+
20+
.. code-block:: javascript
21+
22+
db.collection.find(<query>).close()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
========================
2+
cursor.noCursorTimeout()
3+
========================
4+
5+
.. default-domain:: mongodb
6+
7+
Definition
8+
----------
9+
10+
.. method:: cursor.noCursorTimeout()
11+
12+
Instructs the server to avoid closing a cursor automatically after a period
13+
of inactivity.
14+
15+
The :method:`~cursor.noCursorTimeout()` method has the following
16+
prototype form:
17+
18+
.. code-block:: javascript
19+
20+
db.collection.find(<query>).noCursorTimeout()

source/reference/method/db.collection.find.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,17 @@ array:
381381
Iterate the Returned Cursor
382382
~~~~~~~~~~~~~~~~~~~~~~~~~~~
383383

384-
The :method:`~db.collection.find()` method returns a :term:`cursor` to
385-
the results. In the :program:`mongo` shell, if the returned cursor is
386-
not assigned to a variable using the ``var`` keyword, the cursor is
387-
automatically iterated up to 20 times to access up to the first 20
388-
documents that match the query. You can use the
389-
``DBQuery.shellBatchSize`` to change the number of iterations. See
390-
:ref:`cursor-flags` and :ref:`cursor-behaviors`. To iterate manually,
391-
assign the returned cursor to a variable using the ``var`` keyword.
384+
The :method:`~db.collection.find()` method returns a
385+
:ref:`cursor <read-operations-cursors>` to the results.
386+
387+
In the :program:`mongo` shell, if the returned cursor is not assigned to a
388+
variable using the ``var`` keyword, the cursor is automatically iterated to
389+
access up to the first 20 documents that match the query. You can set the
390+
``DBQuery.shellBatchSize`` variable to change the number of automatically
391+
iterated documents.
392+
393+
To manually iterate over the results, assign the returned cursor to a variable
394+
with the ``var`` keyword, as shown in the following sections.
392395

393396
With Variable Name
394397
``````````````````

source/tutorial/getting-started-with-the-mongo-shell.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ From the :program:`mongo` shell, you can use the :doc:`shell methods
112112
times.
113113

114114
You can set the ``DBQuery.shellBatchSize`` attribute to change the
115-
number of iteration from the default value ``20``, as in the
115+
number of iterations from the default value ``20``, as in the
116116
following example which sets it to ``10``:
117117

118118
.. code-block:: javascript
@@ -290,4 +290,4 @@ Exit the Shell
290290

291291
To exit the shell, type ``quit()`` or use the ``<Ctrl-c>`` shortcut.
292292

293-
.. seealso:: :gettingstarted:`Getting Started Guide </shell>`
293+
.. seealso:: :gettingstarted:`Getting Started Guide </shell>`

0 commit comments

Comments
 (0)