Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ReadPreference

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

see

https://www.mongodb.com/docs/manual/core/read-preference/

Hierarchy

  • ReadPreference

Index

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

  • isValid(mode?: string): boolean
  • Validate if a mode is legal

    Parameters

    • Optional mode: string

      The string representing the read preference mode.

    Returns boolean

  • secondaryOk(): boolean
  • isValid(mode: string): boolean
  • Validate if a mode is legal

    Parameters

    • mode: string

      The string representing the read preference mode.

    Returns boolean

Generated using TypeDoc