Skip to content

[DOCS-364] Document cursor.readPref() #88

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

Merged
merged 2 commits into from
Aug 2, 2012
Merged
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
32 changes: 31 additions & 1 deletion source/reference/javascript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,36 @@ Call cursor methods on cursors to modify how MongoDB returns objects to the curs
database itself. This approach features better index utilization,
if you do not need to easily jump to a specific page.

.. function:: cursor.readPref()

:param string mode: Read preference mode
:param array tagSet: Optional. Array of tag set objects

Append the :func:`readPref() <cursor.readPref()>` to a cursor to control how
the query will be routed to primary and secondary members.

The ``mode`` string should be one of:

- :readmode:`primary`
- :readmode:`primaryPreferred`
- :readmode:`secondary`
- :readmode:`secondaryPreferred`
- :readmode:`nearest`

The ``tagSet`` parameter, if given, should consist of an array of tag set
objects for filtering secondary read operations. For example, a secondary
member tagged ``{ dc: 'ny', rack: 2, size: 'large' }`` will match the tag set
``{ dc: 'ny', rack: 2 }``. Tag sets will be matched in the order they appear
and you may specify an empty tag set ``{}`` as the last element to default to
any available secondary. See the
:ref:`tag sets <replica-set-read-preference-tags>` documentation for more
information.

.. note::

You must apply :func:`cursor.readPref()` to the cursor before retrieving
any documents from the database.

.. function:: cursor.snapshot()

Append the :func:`cursor.snapshot()` method to a cursor to toggle the
Expand Down Expand Up @@ -957,7 +987,7 @@ Database

.. function:: db.killOP(opid)

:param oppid: Specify an operation ID.
:param opid: Specify an operation ID.

Terminates the specified operation. Use :func:`db.currentOp()`
to find operations and their correspoinding ids.
Expand Down