Class: ReadPreference

ReadPreference

new ReadPreference(mode, tags, options){ReadPreference}

Creates a new ReadPreference instance

Read Preferences

  • ReadPreference.PRIMARY, Read from primary only. All operations produce an error (throw an exception where applicable) if primary is unavailable. Cannot be combined with tags (This is the default.).
  • ReadPreference.PRIMARY_PREFERRED, Read from primary if available, otherwise a secondary.
  • ReadPreference.SECONDARY, Read from secondary if available, otherwise error.
  • ReadPreference.SECONDARY_PREFERRED, Read from a secondary if available, otherwise read from the primary.
  • ReadPreference.NEAREST, All modes read from among the nearest candidates, but unlike other modes, NEAREST will include both the primary and all secondaries in the random selection.
Name Type Description
mode string

The ReadPreference mode as listed above.

tags array | object

An object representing read preference tags.

options object optional

Additional read preference options

Name Type Description
maxStalenessSeconds number optional

Max Secondary Read Staleness in Seconds

Returns:
ReadPreference instance.

Methods

staticReadPreference.isValid(mode){boolean}

Validate if a mode is legal

Name Type Description
mode string

The string representing the read preference mode.

isValid(mode){boolean}

Validate if a mode is legal

Name Type Description
mode string

The string representing the read preference mode.