Class ReadPreference

The ReadPreference class is a class that represents a MongoDB ReadPreference and is used to construct connections.

Hierarchy

  • ReadPreference

Constructors

  • Parameters

    • mode: ReadPreferenceMode

      A string describing the read preference mode (primary|primaryPreferred|secondary|secondaryPreferred|nearest)

    • Optional tags: TagSet[]

      A tag set used to target reads to members with the specified tag(s). tagSet is not available if using read preference mode primary.

    • Optional options: ReadPreferenceOptions

      Additional read preference options

    Returns ReadPreference

Properties

hedge?: HedgeOptions
maxStalenessSeconds?: number
minWireVersion?: number
tags?: TagSet[]
NEAREST: "nearest" = ReadPreferenceMode.nearest
PRIMARY: "primary" = ReadPreferenceMode.primary
PRIMARY_PREFERRED: "primaryPreferred" = ReadPreferenceMode.primaryPreferred
SECONDARY: "secondary" = ReadPreferenceMode.secondary
SECONDARY_PREFERRED: "secondaryPreferred" = ReadPreferenceMode.secondaryPreferred
nearest: ReadPreference = ...
primary: ReadPreference = ...
primaryPreferred: ReadPreference = ...
secondary: ReadPreference = ...
secondaryPreferred: ReadPreference = ...

Accessors

Methods

  • Check if the two ReadPreferences are equivalent

    Parameters

    • readPreference: ReadPreference

      The read preference with which to check equality

    Returns boolean

  • Validate if a mode is legal

    Parameters

    • Optional mode: string

      The string representing the read preference mode.

    Returns boolean

  • Validate if a mode is legal

    Parameters

    • mode: string

      The string representing the read preference mode.

    Returns boolean

Generated using TypeDoc