Skip to content

DOCS-1040 addOption edits to page to include multiple options and link to specific section #853

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions source/reference/method/cursor.addOption.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,33 @@ cursor.addOption()
.. method:: cursor.addOption(<flag>)

Use the :method:`cursor.addOption()` method on a cursor to add
``OP_QUERY`` wire protocol flags, such as the ``tailable`` flag.
``OP_QUERY`` wire protocol flags, such as the ``tailable`` flag, to
change the behavior of queries.

:param flag: ``OP_QUERY`` wire protocol flag. See :meta-driver:`MongoDB
wire protocol </legacy/mongodb-wire-protocol>` for more
information on MongoDB Wire Protocols and the OP_QUERY
flags.
wire protocol
</legacy/mongodb-wire-protocol/?pageVersion=106#op-query>`
for more information on MongoDB Wire Protocols and
the OP_QUERY flags.

For the :program:`mongo` shell, see the list of :ref:`cursor flags
<cursor-flags>` available in the shell. For the driver-specific
list, see your :doc:`driver documentation </applications/drivers>`.
For the :program:`mongo` shell, you can use the cursor
flags listed in the :ref:`cursor-flags` section. For
the driver-specific list, see your :doc:`driver
documentation </applications/drivers>`.

The following example in the :program:`mongo` shell adds the
``DBQuery.Option.tailable`` flag to ensure the cursor returned from
the query is a tailable cursor:
``DBQuery.Option.tailable`` flag and the
``DBQuery.Option.awaitData`` flag to ensure that the cursor returned
from the query is a tailable cursor that waits for a few seconds for
new data when you reach the end of the data:

.. code-block:: javascript

var t = db.myCappedCollection;
var cursor = t.find().addOption(DBQuery.Option.tailable);
var cursor = t.find().addOption(DBQuery.Option.tailable).
addOption(DBQuery.Option.awaitData)

.. warning::

.. warning::

Adding incorrect wire protocol flags can cause problems and/or
extra server load.