-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathSessionOptions.txt
103 lines (65 loc) · 2.93 KB
/
SessionOptions.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
==============
SessionOptions
==============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: SessionOptions
The options for a :method:`session <Mongo.startSession()>` in
:binary:`~bin.mongosh`. To access the :method:`SessionOptions`
object, use the :method:`Session.getOptions()` method.
The session options available are:
.. list-table::
:header-rows: 1
:widths: 20 80
* - Option
- Description
* - ``causalConsistency``
- Boolean. Enables or disables :ref:`causal consistency
<causal-consistency>` for the session.
You can explicitly set the option when you start a session
manually:
- ``Session = db.getMongo().startSession( { causalConsistency: true } )``
* - ``readConcern``
- Document. Specifies the :ref:`read concern <read-concern>`.
In :binary:`~bin.mongosh`, you can set the option when
you run :method:`Mongo.startSession()`. You can also access
the ``readConcern`` option via the following methods:
- ``Session.getOptions().getReadConcern()``
- ``Session.getOptions().setReadConcern(<document>)``
* - ``readPreference``
- Document. Specifies the :ref:`read preference <read-preference>`.
In :binary:`~bin.mongosh`, you can set the option
when you run :method:`Mongo.startSession()`. You can also
access the ``readPreference`` option via the following
methods:
- ``Session.getOptions().getReadPreference()``
- ``Session.getOptions().setReadPreference({ mode: <string>, tags: <array>})``
* - ``retryWrites``
- Boolean. Enables or disables the ability to retry writes upon
encountering transient network errors, such as during
failovers.
To enable retry writes, start :binary:`~bin.mongosh`
with the :option:`--retryWrites <mongosh --retryWrites>` option.
You can view whether ``retryWrites`` is enabled for a session
via the following method:
- ``Session.getOptions().shouldRetryWrites()``
* - ``writeConcern``
- Document. Specifies the :ref:`write concern <write-concern>`.
In :binary:`~bin.mongosh`, you can set the options
when you run :method:`Mongo.startSession()`. You can also
access the ``writeConcern`` option via the following methods:
- ``Session.getOptions().getWriteConcern()``
- ``Session.getOptions().setWriteConcern(<document>)``
Verify which options are enabled for the session by running
``Session.getOptions()``.
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