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
    • Optional options: ReadPreferenceOptions

      Additional read preference options

      Optional

    Returns ReadPreference

Properties

hedge?: HedgeOptions
maxStalenessSeconds?: number
minWireVersion?: number
tags?: TagSet[]
NEAREST: "nearest"
PRIMARY: "primary"
PRIMARY_PREFERRED: "primaryPreferred"
SECONDARY: "secondary"
SECONDARY_PREFERRED: "secondaryPreferred"
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.

      Optional

    Returns boolean

  • Construct a ReadPreference given an options object.

    Parameters

    Returns ReadPreference

  • Parameters

    • mode: string

    Returns ReadPreference

  • Validate if a mode is legal

    Parameters

    • mode: string

      The string representing the read preference mode.

    Returns boolean

Generated using TypeDoc