ReadPreference class

The ReadPreference class is a class that represents a MongoDB ReadPreference and is used to construct connections. @class @param {string} mode A string describing the read preference mode (primary|primaryPreferred|secondary|secondaryPreferred|nearest) @param {array} tags The tags object @param {object} options Additional read preference options @param {number} options.maxStalenessSeconds Max secondary read staleness in seconds, Minimum value is 90 seconds. @see https://docs.mongodb.com/manual/core/read-preference/ @return {ReadPreference}

Constructors

ReadPreference(ReadPreferenceMode mode, {List? tags, int? maxStalenessSeconds, Map<String, Object>? hedgeOptions})
ReadPreference.fromOptions(Map<String, Object> options)
We can accept three formats for ReadPreference inside Options:
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
hedgeOptions Map<String, Object>?
final
maxStalenessSeconds int?
final
mode ReadPreferenceMode
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
slaveOk bool
Indicates that this readPreference needs the "slaveOk" bit when sent over the wire @method @return {boolean} @see https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query
no setter
tags List?
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() Map<String, Object>
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

nearest ReadPreference
getter/setter pair
primary ReadPreference
getter/setter pair
primaryPreferred ReadPreference
getter/setter pair
secondary ReadPreference
getter/setter pair
secondaryPreferred ReadPreference
getter/setter pair

Static Methods

getMaxStalenessSeconds(Map<String, Object>? options) int?

Constants

needSlaveOk → const List<ReadPreferenceMode>