MongoClientOptions
public struct MongoClientOptions : CodingStrategyProvider
Options to use when creating a MongoClient
.
-
Specifies authentication options for use with the client.
Declaration
Swift
public var credential: MongoCredential?
-
Specifies the
DataCodingStrategy
to use for BSON encoding/decoding operations performed by this client and any databases or collections that derive from it.Declaration
Swift
public var dataCodingStrategy: DataCodingStrategy?
-
Specifies the
DateCodingStrategy
to use for BSON encoding/decoding operations performed by this client and any databases or collections that derive from it.Declaration
Swift
public var dateCodingStrategy: DateCodingStrategy?
-
When true, the client will connect directly to a single host. When false, the client will attempt to automatically discover all replica set members if a replica set name is provided. Defaults to false. It is an error to set this option to
true
when used with a mongodb+srv connection string or when multiple hosts are specified in the connection string.Declaration
Swift
public var directConnection: Bool?
-
The maximum number of connections that may be associated with a connection pool created by this client at a given time. This includes in-use and available connections. Defaults to 100.
Declaration
Swift
public var maxPoolSize: Int?
-
Specifies a ReadConcern to use for the client.
Declaration
Swift
public var readConcern: ReadConcern?
-
Specifies a ReadPreference to use for the client.
Declaration
Swift
public var readPreference: ReadPreference?
-
Determines whether the client should retry supported read operations (on by default).
Declaration
Swift
public var retryReads: Bool?
-
Determines whether the client should retry supported write operations (on by default).
Declaration
Swift
public var retryWrites: Bool?
-
MongoSwift.MongoClient
provides an asynchronous API by running all blocking operations off of their originating threads in a thread pool.MongoSwiftSync.MongoClient
is implemented as a wrapper of the async client which waits for each corresponding asynchronous operation to complete and then returns the result. This option specifies the size of the thread pool used by the asynchronous client, and determines the max number of concurrent operations that may be performed using a single client. Defaults to 5.Declaration
Swift
public var threadPoolSize: Int?
-
Whether or not to require TLS for connections to the server. By default this is set to false.
Note
Specifying any other “tls”-prefixed option will require TLS for connections to the server.Declaration
Swift
public var tls: Bool?
-
Indicates whether to bypass validation of the certificate presented by the mongod/mongos instance. By default this is set to false.
Declaration
Swift
public var tlsAllowInvalidCertificates: Bool?
-
Indicates whether to disable hostname validation for the certificate presented by the mongod/mongos instance. By default this is set to false.
Declaration
Swift
public var tlsAllowInvalidHostnames: Bool?
-
Specifies the location of a local .pem file that contains the root certificate chain from the Certificate Authority. This file is used to validate the certificate presented by the mongod/mongos instance.
Declaration
Swift
public var tlsCAFile: URL?
-
Specifies the location of a local .pem file that contains either the client’s TLS certificate or the client’s TLS certificate and key. The client presents this file to the mongod/mongos instance.
Declaration
Swift
public var tlsCertificateKeyFile: URL?
-
Specifies the password to de-crypt the
tlsCertificateKeyFile
.Declaration
Swift
public var tlsCertificateKeyFilePassword: String?
-
Specifies the
UUIDCodingStrategy
to use for BSON encoding/decoding operations performed by this client and any databases or collections that derive from it.Declaration
Swift
public var uuidCodingStrategy: UUIDCodingStrategy?
-
Specifies a WriteConcern to use for the client.
Declaration
Swift
public var writeConcern: WriteConcern?
-
init(credential:
dataCodingStrategy: dateCodingStrategy: directConnection: maxPoolSize: readConcern: readPreference: retryReads: retryWrites: threadPoolSize: tls: tlsAllowInvalidCertificates: tlsAllowInvalidHostnames: tlsCAFile: tlsCertificateKeyFile: tlsCertificateKeyFilePassword: uuidCodingStrategy: writeConcern: ) Convenience initializer allowing any/all parameters to be omitted or optional.
Declaration
Swift
public init( credential: MongoCredential? = nil, dataCodingStrategy: DataCodingStrategy? = nil, dateCodingStrategy: DateCodingStrategy? = nil, directConnection: Bool? = nil, maxPoolSize: Int? = nil, readConcern: ReadConcern? = nil, readPreference: ReadPreference? = nil, retryReads: Bool? = nil, retryWrites: Bool? = nil, threadPoolSize: Int? = nil, tls: Bool? = nil, tlsAllowInvalidCertificates: Bool? = nil, tlsAllowInvalidHostnames: Bool? = nil, tlsCAFile: URL? = nil, tlsCertificateKeyFile: URL? = nil, tlsCertificateKeyFilePassword: String? = nil, uuidCodingStrategy: UUIDCodingStrategy? = nil, writeConcern: WriteConcern? = nil )