WriteConcern
public struct WriteConcern : Codable
extension WriteConcern: CustomStringConvertible
extension WriteConcern: Equatable
A class to represent a MongoDB write concern.
-
Majority WriteConcern with journal and wtimeoutMS unset.
Declaration
Swift
public static let majority: WriteConcern
-
Returns a customized Majority WriteConcern.
Declaration
Swift
public static func majority(wtimeoutMS: Int? = nil, journal: Bool? = nil) throws -> WriteConcern
Parameters
wtimeoutMS
The maximum amount of time, in milliseconds, that the primary will wait for the write concern to be satisfied before returning a WriteConcernError.
journal
requests acknowledgment that the mongod instances have written to the on-disk journal.
-
Server default WriteConcern.
Declaration
Swift
public static let serverDefault: WriteConcern
-
An option to request acknowledgement that the write operation has propagated to specified mongod instances.
See moreDeclaration
Swift
public enum W : Codable, Equatable
-
Indicates whether to wait for the write operation to get committed to the journal.
Declaration
Swift
public let journal: Bool?
-
If the write concern is not satisfied within this timeout (in milliseconds), the operation will return an error. The value MUST be greater than or equal to 0.
Declaration
Swift
public let wtimeoutMS: Int?
-
Indicates whether this is an acknowledged write concern.
Declaration
Swift
public var isAcknowledged: Bool { get }
-
Indicates whether this is the default write concern.
Declaration
Swift
public var isDefault: Bool { get }
-
Initializes a new, empty
WriteConcern
.Declaration
Swift
public init()
-
Initializes a new
WriteConcern
.Throws
MongoError.InvalidArgumentError
if the options form an invalid combination.
Declaration
Swift
public init(journal: Bool? = nil, w: W? = nil, wtimeoutMS: Int? = nil) throws
-
Returns the relaxed extended JSON representation of this
WriteConcern
. On error, an empty string will be returned.Declaration
Swift
public var description: String { get }