ReadPreference

public final class ReadPreference

A class to represent a MongoDB read preference.

  • An enumeration of possible ReadPreference modes.

    See more

    Declaration

    Swift

    public enum Mode : String
  • The mode of this ReadPreference

    Declaration

    Swift

    public var mode: Mode { get }
  • The tags of this ReadPreference

    Declaration

    Swift

    public var tagSets: [Document] { get }
  • The maxStalenessSeconds of this ReadPreference

    Declaration

    Swift

    public var maxStalenessSeconds: Int64? { get }
  • Initializes a ReadPreference from a Mode.

    Declaration

    Swift

    public init(_ mode: Mode)

    Parameters

    mode

    a Mode

    Return Value

    a new ReadPreference

  • Initializes a ReadPreference.

    Throws

    Throws:

    • A UserError.invalidArgumentError if mode is .primary and tagSets is non-empty
    • A UserError.invalidArgumentError if maxStalenessSeconds non-nil and < 90

    Declaration

    Swift

    public init(_ mode: Mode, tagSets: [Document]? = nil, maxStalenessSeconds: Int64? = nil) throws

    Parameters

    mode

    a Mode

    tagSets

    an optional [Document]

    maxStalenessSeconds

    an optional Int64

    Return Value

    a new ReadPreference

  • Initializes a new ReadPreference by copying an existing ReadPreference.

    Declaration

    Swift

    public init(from readPreference: ReadPreference)
  • Declaration

    Swift

    public static func == (lhs: ReadPreference, rhs: ReadPreference) -> Bool