Definition
SessionOptionsNew in version 3.6.
The options for a
sessionin themongoshell. To access theSessionOptions()object, use theSession.getOptions()method.The session options available are:
OptionDescriptioncausalConsistencyBoolean. Enables or disables causal consistency for the session.
In the
mongoshell,Mongo.startSession()enablescausalConsistencyby default. You can also explicitly set the option when you runMongo.startSession().You can view whether
causalConsistencyis enabled for the session via the following method:Session.getOptions().isCausalConsistency()
readConcernDocument. Specifies the read concern.
In the
mongoshell, you can set the option when you runMongo.startSession(). You can also access thereadConcernoption via the following methods:Session.getOptions().getReadConcern()Session.getOptions().setReadConcern(<document>)
readPreferenceDocument. Specifies the read preference.
In the
mongoshell, you can set the option when you runMongo.startSession(). You can also access thereadPreferenceoption via the following methods:Session.getOptions().getReadPreference()Session.getOptions().setReadPreference({ mode: <string>, tags: <array>})
retryWritesBoolean. Enables or disables the ability to retry writes upon encountering transient network errors, such as during failovers.
To enable retry writes, start the
mongoshell with the--retryWritesoption.You can view whether
retryWritesis enabled for a session via the following method:Session.getOptions().shouldRetryWrites()
writeConcernDocument. Specifies the write concern.
In the
mongoshell, you can set the options when you runMongo.startSession(). You can also access thewriteConcernoption via the following methods:Session.getOptions().getWriteConcern()Session.getOptions().setWriteConcern(<document>)