Skip to content

Commit 1021d2b

Browse files
committed
DOCS-860 add the cursor.addOption method
1 parent 307609e commit 1021d2b

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
==================
2+
cursor.addOption()
3+
==================
4+
5+
.. default-domain:: mongodb
6+
7+
.. method:: cursor.addOption(<flag>)
8+
9+
Use the :method:`cursor.addOption()` method on a cursor to add
10+
OP_QUERY wire protocol flags, such as the ``tailable`` flag.
11+
12+
:param flag: OP_Query wire protocol flag. See :meta-driver:`MongoDB
13+
wire protocol </legacy/mongodb-wire-protocol>` for more
14+
information on MongoDB Wire Protocols and the OP_Query flags.
15+
16+
For the :program:`mongo` shell, see the list of :ref:`cursor flags
17+
<cursor-flags>` available in the shell. For the driver-specific
18+
list, see your :doc:`driver documentation </applications/drivers>`.
19+
20+
The following example in the :program:`mongo` shell adds the
21+
``DBQuery.Option.tailable`` and ``DBQuery.Option.awaitData`` flags
22+
to ensure the cursor returned from the query is a tailable cursor
23+
that waits for a few seconds when the cursor reaches the end of the
24+
data:
25+
26+
.. code-block:: javascript
27+
28+
var cursor = db.myCappedCollection.find().addOption( DBQuery.Option.tailable ).addOption( DBQuery.Option.awaitData );

source/tutorial/create-tailable-cursor.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ Consider the following behaviors related to tailable cursors:
5454
A *dead* cursor has an id of ``0``.
5555

5656
See your :doc:`driver documentation </applications/drivers>` for the
57-
driver-specific method to specify the tailable cursor. For more
57+
driver-specific method to specify the tailable cursor. For more
5858
information on the details of specifying a tailable cursor, see
59-
:meta-driver:`Mongo wire protocol </legacy/mongodb-wire-protocol>` documentation.
59+
:meta-driver:`MongoDB wire protocol </legacy/mongodb-wire-protocol>`
60+
documentation.
6061

6162
C++ Example
6263
-----------

0 commit comments

Comments
 (0)