Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Sources/MongoSwift/MongoClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import mongoc
/// Options to use when creating a `MongoClient`.
public struct ClientOptions: CodingStrategyProvider, Decodable {
/// Determines whether the client should retry supported write operations.
public let retryWrites: Bool?
public var retryWrites: Bool?

/// Indicates whether this client should be set up to enable monitoring command and server discovery and monitoring
/// events.
public let eventMonitoring: Bool
public var eventMonitoring: Bool

/// Specifies a ReadConcern to use for the client. If one is not specified, the server's default read concern will
/// be used.
public let readConcern: ReadConcern?
public var readConcern: ReadConcern?

/// Specifies a WriteConcern to use for the client. If one is not specified, the server's default write concern
/// will be used.
public let writeConcern: WriteConcern?
public var writeConcern: WriteConcern?

// swiftlint:disable redundant_optional_initialization

Expand Down Expand Up @@ -64,10 +64,10 @@ public struct ClientOptions: CodingStrategyProvider, Decodable {
/// Options to use when listing available databases.
public struct ListDatabasesOptions: Encodable {
/// An optional filter for the returned databases.
public let filter: Document?
public var filter: Document?

/// Optionally indicate whether only names should be returned.
public let nameOnly: Bool?
public var nameOnly: Bool?

/// Convenience constructor for basic construction
public init(filter: Document? = nil, nameOnly: Bool? = nil) {
Expand All @@ -80,27 +80,27 @@ public struct ListDatabasesOptions: Encodable {
public struct DatabaseOptions: CodingStrategyProvider {
/// A read concern to set on the retrieved database. If one is not specified, the database will inherit the
/// client's read concern.
public let readConcern: ReadConcern?
public var readConcern: ReadConcern?

/// A read preference to set on the retrieved database. If one is not specified, the database will inherit the
/// client's read preference.
public let readPreference: ReadPreference?
public var readPreference: ReadPreference?

/// A write concern to set on the retrieved database. If one is not specified, the database will inherit the
/// client's write concern.
public let writeConcern: WriteConcern?
public var writeConcern: WriteConcern?

/// Specifies the `DateCodingStrategy` to use for BSON encoding/decoding operations performed by this database and
/// any collections that derive from it.
public let dateCodingStrategy: DateCodingStrategy?
public var dateCodingStrategy: DateCodingStrategy?

/// Specifies the `DateCodingStrategy` to use for BSON encoding/decoding operations performed by this database and
/// any collections that derive from it.
public let uuidCodingStrategy: UUIDCodingStrategy?
public var uuidCodingStrategy: UUIDCodingStrategy?

/// Specifies the `DateCodingStrategy` to use for BSON encoding/decoding operations performed by this database and
/// any collections that derive from it.
public let dataCodingStrategy: DataCodingStrategy?
public var dataCodingStrategy: DataCodingStrategy?

/// Convenience initializer allowing any/all arguments to be omitted or optional.
public init(readConcern: ReadConcern? = nil,
Expand Down
6 changes: 3 additions & 3 deletions Sources/MongoSwift/MongoCollection+BulkWrite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public class BulkWriteOperation: Operation {
/// Options to use when performing a bulk write operation on a `MongoCollection`.
public struct BulkWriteOptions: Codable {
/// If `true`, allows the write to opt-out of document level validation.
public let bypassDocumentValidation: Bool?
public var bypassDocumentValidation: Bool?

/**
* If `true` (the default), operations will be executed serially in order
Expand All @@ -432,10 +432,10 @@ public struct BulkWriteOptions: Codable {
* not stop after encountering a write error (i.e. multiple errors may be
* reported after all operations have been attempted).
*/
public let ordered: Bool
public var ordered: Bool

/// An optional WriteConcern to use for the bulk write.
public let writeConcern: WriteConcern?
public var writeConcern: WriteConcern?

/// Convenience initializer allowing any/all parameters to be omitted or optional
public init(bypassDocumentValidation: Bool? = nil, ordered: Bool? = nil, writeConcern: WriteConcern? = nil) {
Expand Down
44 changes: 22 additions & 22 deletions Sources/MongoSwift/MongoCollection+FindAndModify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ internal protocol FindAndModifyOptionsConvertible {
/// Options to use when executing a `findOneAndDelete` command on a `MongoCollection`.
public struct FindOneAndDeleteOptions: FindAndModifyOptionsConvertible, Decodable {
/// Specifies a collation to use.
public let collation: Document?
public var collation: Document?

/// The maximum amount of time to allow the query to run.
public let maxTimeMS: Int64?
public var maxTimeMS: Int64?

/// Limits the fields to return for the matching document.
public let projection: Document?
public var projection: Document?

/// Determines which document the operation modifies if the query selects multiple documents.
public let sort: Document?
public var sort: Document?

/// An optional `WriteConcern` to use for the command.
public let writeConcern: WriteConcern?
public var writeConcern: WriteConcern?

internal func asFindAndModifyOptions() throws -> FindAndModifyOptions {
return try FindAndModifyOptions(collation: collation,
Expand Down Expand Up @@ -163,28 +163,28 @@ public struct FindOneAndDeleteOptions: FindAndModifyOptionsConvertible, Decodabl
/// Options to use when executing a `findOneAndReplace` command on a `MongoCollection`.
public struct FindOneAndReplaceOptions: FindAndModifyOptionsConvertible, Decodable {
/// If `true`, allows the write to opt-out of document level validation.
public let bypassDocumentValidation: Bool?
public var bypassDocumentValidation: Bool?

/// Specifies a collation to use.
public let collation: Document?
public var collation: Document?

/// The maximum amount of time to allow the query to run.
public let maxTimeMS: Int64?
public var maxTimeMS: Int64?

/// Limits the fields to return for the matching document.
public let projection: Document?
public var projection: Document?

/// When `ReturnDocument.After`, returns the replaced or inserted document rather than the original.
public let returnDocument: ReturnDocument?
public var returnDocument: ReturnDocument?

/// Determines which document the operation modifies if the query selects multiple documents.
public let sort: Document?
public var sort: Document?

/// When `true`, creates a new document if no document matches the query.
public let upsert: Bool?
public var upsert: Bool?

/// An optional `WriteConcern` to use for the command.
public let writeConcern: WriteConcern?
public var writeConcern: WriteConcern?

internal func asFindAndModifyOptions() throws -> FindAndModifyOptions {
return try FindAndModifyOptions(bypassDocumentValidation: bypassDocumentValidation,
Expand Down Expand Up @@ -220,31 +220,31 @@ public struct FindOneAndReplaceOptions: FindAndModifyOptionsConvertible, Decodab
/// Options to use when executing a `findOneAndUpdate` command on a `MongoCollection`.
public struct FindOneAndUpdateOptions: FindAndModifyOptionsConvertible, Decodable {
/// A set of filters specifying to which array elements an update should apply.
public let arrayFilters: [Document]?
public var arrayFilters: [Document]?

/// If `true`, allows the write to opt-out of document level validation.
public let bypassDocumentValidation: Bool?
public var bypassDocumentValidation: Bool?

/// Specifies a collation to use.
public let collation: Document?
public var collation: Document?

/// The maximum amount of time to allow the query to run.
public let maxTimeMS: Int64?
public var maxTimeMS: Int64?

/// Limits the fields to return for the matching document.
public let projection: Document?
public var projection: Document?

/// When`ReturnDocument.After`, returns the updated or inserted document rather than the original.
public let returnDocument: ReturnDocument?
public var returnDocument: ReturnDocument?

/// Determines which document the operation modifies if the query selects multiple documents.
public let sort: Document?
public var sort: Document?

/// When `true`, creates a new document if no document matches the query.
public let upsert: Bool?
public var upsert: Bool?

/// An optional `WriteConcern` to use for the command.
public let writeConcern: WriteConcern?
public var writeConcern: WriteConcern?

internal func asFindAndModifyOptions() throws -> FindAndModifyOptions {
return try FindAndModifyOptions(arrayFilters: arrayFilters,
Expand Down
32 changes: 16 additions & 16 deletions Sources/MongoSwift/MongoCollection+Indexes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public struct IndexModel: Encodable {
/// Options to use when creating an index for a collection.
public struct IndexOptions: Codable {
/// Optionally tells the server to build the index in the background and not block other tasks.
public let background: Bool?
public var background: Bool?

/// Optionally specifies the length in time, in seconds, for documents to remain in a collection.
public let expireAfterSeconds: Int32?
public var expireAfterSeconds: Int32?

/**
* Optionally specify a specific name for the index outside of the default generated name. If none is provided then
Expand All @@ -51,54 +51,54 @@ public struct IndexOptions: Codable {
public var name: String?

/// Optionally tells the index to only reference documents with the specified field in the index.
public let sparse: Bool?
public var sparse: Bool?

/// Optionally used only in MongoDB 3.0.0 and higher. Allows users to configure the storage engine on a per-index
/// basis when creating an index.
public let storageEngine: Document?
public var storageEngine: Document?

/// Optionally forces the index to be unique.
public let unique: Bool?
public var unique: Bool?

/// Optionally specifies the index version number, either 0 or 1.
public var indexVersion: Int32?

/// Optionally specifies the default language for text indexes. Is 'english' if none is provided.
public let defaultLanguage: String?
public var defaultLanguage: String?

/// Optionally specifies the field in the document to override the language.
public let languageOverride: String?
public var languageOverride: String?

/// Optionally provides the text index version number. MongoDB 2.4 can only support version 1. MongoDB 2.6 and
/// higher may support version 1 or 2.
public let textIndexVersion: Int32?
public var textIndexVersion: Int32?

/// Optionally specifies fields in the index and their corresponding weight values.
public let weights: Document?
public var weights: Document?

/// Optionally specifies the 2dsphere index version number. MongoDB 2.4 can only support version 1. MongoDB 2.6 and
/// higher may support version 1 or 2.
public let sphereIndexVersion: Int32?
public var sphereIndexVersion: Int32?

/// Optionally specifies the precision of the stored geo hash in the 2d index, from 1 to 32.
public let bits: Int32?
public var bits: Int32?

/// Optionally sets the maximum boundary for latitude and longitude in the 2d index.
public let max: Double?
public var max: Double?

/// Optionally sets the minimum boundary for latitude and longitude in the index in a 2d index.
public let min: Double?
public var min: Double?

/// Optionally specifies the number of units within which to group the location values in a geo haystack index.
public let bucketSize: Int32?
public var bucketSize: Int32?

/// Optionally specifies a filter for use in a partial index. Only documents that match the filter expression are
/// included in the index. New in MongoDB 3.2.
public let partialFilterExpression: Document?
public var partialFilterExpression: Document?

/// Optionally specifies a collation to use for the index in MongoDB 3.4 and higher. If not specified, no collation
/// is sent and the default collation of the collection server-side is used.
public let collation: Document?
public var collation: Document?

/// Convenience initializer allowing any/all parameters to be omitted.
public init(background: Bool? = nil,
Expand Down
Loading