Class: ReadPreference

ReadPreference

new ReadPreference(mode, tags){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 object

An object representing read preference tags.

Properties:
Name Type Description
mode string

The ReadPreference mode.

tags object

The ReadPreference tags.

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.

comments powered by Disqus