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

constructor

  • 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

Optional hedge

hedge?: HedgeOptions

Optional maxStalenessSeconds

maxStalenessSeconds?: number

Optional minWireVersion

minWireVersion?: number

mode

Optional tags

tags?: TagSet[]

Static NEAREST

NEAREST: "nearest" = ...

Static PRIMARY

PRIMARY: "primary" = ...

Static PRIMARY_PREFERRED

PRIMARY_PREFERRED: "primaryPreferred" = ...

Static SECONDARY

SECONDARY: "secondary" = ...

Static SECONDARY_PREFERRED

SECONDARY_PREFERRED: "secondaryPreferred" = ...

Static nearest

nearest: ReadPreference = ...

Static primary

primary: ReadPreference = ...

Static primaryPreferred

primaryPreferred: ReadPreference = ...

Static secondary

secondary: ReadPreference = ...

Static secondaryPreferred

secondaryPreferred: ReadPreference = ...

Accessors

preference

Methods

equals

isValid

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

    Parameters

    • Optional mode: string

      The string representing the read preference mode.

    Returns boolean

slaveOk

  • slaveOk(): boolean

toJSON

Static fromOptions

Static fromString

Static isValid

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

    Parameters

    • mode: string

      The string representing the read preference mode.

    Returns boolean

Static translate

Generated using TypeDoc