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://docs.mongodb.com/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

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

  • Check if the two ReadPreferences are equivalent

    Parameters参数

    • readPreference: ReadPreference

      The read preference with which to check equality

    Returns返回boolean

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