-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathMongo.getReadPrefMode.txt
57 lines (39 loc) · 1.38 KB
/
Mongo.getReadPrefMode.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
=======================
Mongo.getReadPrefMode()
=======================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. method:: Mongo.getReadPrefMode()
:returns: The current :term:`read preference` mode for the
:method:`Mongo() <db.getMongo()>` connection object.
See :doc:`/core/read-preference` for an introduction to read
preferences in MongoDB. Use :method:`~Mongo.getReadPrefMode()` to
return the current read preference mode, as in the following
example:
.. code-block:: javascript
db.getMongo().getReadPrefMode()
Use the following operation to return and print the current read
preference mode:
.. code-block:: javascript
print(db.getMongo().getReadPrefMode());
This operation will return one of the following read preference
modes:
- :readmode:`primary`
- :readmode:`primaryPreferred`
- :readmode:`secondary`
- :readmode:`secondaryPreferred`
- :readmode:`nearest`
Compatibility
-------------
This method is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-onprem-only.rst
.. seealso::
- :doc:`/core/read-preference`
- :method:`~cursor.readPref()`
- :method:`~Mongo.setReadPref()`
- :method:`~Mongo.getReadPrefTagSet()`