API 参考
    正在准备搜索索引...

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

    索引

    构造函数

    • 参数

      • mode: ReadPreferenceMode

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

      • 可选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.

      • 可选options: ReadPreferenceOptions

        Additional read preference options

      返回 ReadPreference

    属性

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

    访问器

    • get preference(): ReadPreferenceMode

      返回 ReadPreferenceMode

    方法

    • Check if the two ReadPreferences are equivalent

      参数

      • readPreference: ReadPreference

        The read preference with which to check equality

      返回 boolean

    • Validate if a mode is legal

      参数

      • 可选mode: string

        The string representing the read preference mode.

      返回 boolean

    • Indicates that this readPreference needs the "SecondaryOk" bit when sent over the wire

      返回 boolean

    • Return JSON representation

      返回 Document

    • Construct a ReadPreference given an options object.

      参数

      返回 undefined | ReadPreference

    • 参数

      • mode: string

      返回 ReadPreference

    • Validate if a mode is legal

      参数

      • mode: string

        The string representing the read preference mode.

      返回 boolean