ReplaceOneModel

public struct ReplaceOneModel : WriteModel, Decodable

A model for a replaceOne operation within a bulk write.

  • A Document representing the match criteria.

    Declaration

    Swift

    public let filter: Document
  • The CollectionType to use as the replacement value.

    Declaration

    Swift

    public let replacement: CollectionType
  • The collation to use.

    Declaration

    Swift

    public let collation: Document?
  • When true, creates a new document if no document matches the query.

    Declaration

    Swift

    public let upsert: Bool?
  • Create a replaceOne operation for a bulk write.

    Declaration

    Swift

    public init(filter: Document, replacement: CollectionType, collation: Document? = nil, upsert: Bool? = nil)

    Parameters

    filter

    A Document representing the match criteria.

    replacement

    The CollectionType to use as the replacement value.

    collation

    Specifies a collation to use.

    upsert

    When true, creates a new document if no document matches the query.

  • Adds the replaceOne operation to a bulk write.

    Throws

    • EncodingError if an error occurs while encoding the CollectionType or options to BSON.
    • UserError.invalidArgumentError if the options form an invalid combination.

    Declaration

    Swift

    public func addToBulkWrite(bulk: BulkWriteOperation, index: Int) throws