From ca97f99caec54211610ee1f1ef7da1ef1dcbbf68 Mon Sep 17 00:00:00 2001 From: Nataly Carbonell Date: Wed, 29 May 2019 17:25:10 -0400 Subject: [PATCH 1/3] Make option properties mutable --- Sources/MongoSwift/MongoCollection+BulkWrite.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/MongoSwift/MongoCollection+BulkWrite.swift b/Sources/MongoSwift/MongoCollection+BulkWrite.swift index 891ead8d1..22c9310ba 100644 --- a/Sources/MongoSwift/MongoCollection+BulkWrite.swift +++ b/Sources/MongoSwift/MongoCollection+BulkWrite.swift @@ -37,7 +37,7 @@ extension MongoCollection { } private struct DeleteModelOptions: Encodable { - public let collation: Document? + public var collation: Document? } /// A model for a `deleteOne` operation within a bulk write. @@ -154,8 +154,8 @@ extension MongoCollection { } private struct ReplaceOneModelOptions: Encodable { - public let collation: Document? - public let upsert: Bool? + public var collation: Document? + public var upsert: Bool? } /// A model for a `replaceOne` operation within a bulk write. From ac2676f2d50b33157f1fddb555b51d73d7efe285 Mon Sep 17 00:00:00 2001 From: ncarbon Date: Thu, 30 May 2019 10:15:31 -0400 Subject: [PATCH 2/3] Change private option properties back to immutable --- Sources/MongoSwift/MongoCollection+BulkWrite.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/MongoSwift/MongoCollection+BulkWrite.swift b/Sources/MongoSwift/MongoCollection+BulkWrite.swift index 22c9310ba..891ead8d1 100644 --- a/Sources/MongoSwift/MongoCollection+BulkWrite.swift +++ b/Sources/MongoSwift/MongoCollection+BulkWrite.swift @@ -37,7 +37,7 @@ extension MongoCollection { } private struct DeleteModelOptions: Encodable { - public var collation: Document? + public let collation: Document? } /// A model for a `deleteOne` operation within a bulk write. @@ -154,8 +154,8 @@ extension MongoCollection { } private struct ReplaceOneModelOptions: Encodable { - public var collation: Document? - public var upsert: Bool? + public let collation: Document? + public let upsert: Bool? } /// A model for a `replaceOne` operation within a bulk write. From e6fa19b8c7ace05e70d62eb432c1b9ab7144445e Mon Sep 17 00:00:00 2001 From: ncarbon Date: Thu, 30 May 2019 15:58:06 -0400 Subject: [PATCH 3/3] Make ReadPreference getters return non-optionals --- Sources/MongoSwift/MongoClient.swift | 2 +- Sources/MongoSwift/MongoCollection.swift | 2 +- Sources/MongoSwift/MongoDatabase.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/MongoSwift/MongoClient.swift b/Sources/MongoSwift/MongoClient.swift index eafb91085..573b20f5f 100644 --- a/Sources/MongoSwift/MongoClient.swift +++ b/Sources/MongoSwift/MongoClient.swift @@ -142,7 +142,7 @@ public class MongoClient { } /// The `ReadPreference` set on this client - public var readPreference: ReadPreference? { + public var readPreference: ReadPreference { return ReadPreference(from: mongoc_client_get_read_prefs(self._client)) } diff --git a/Sources/MongoSwift/MongoCollection.swift b/Sources/MongoSwift/MongoCollection.swift index 6ad294ed6..208332e68 100644 --- a/Sources/MongoSwift/MongoCollection.swift +++ b/Sources/MongoSwift/MongoCollection.swift @@ -39,7 +39,7 @@ public class MongoCollection { } /// The `ReadPreference` set on this collection. - public var readPreference: ReadPreference? { + public var readPreference: ReadPreference { return ReadPreference(from: mongoc_collection_get_read_prefs(self._collection)) } diff --git a/Sources/MongoSwift/MongoDatabase.swift b/Sources/MongoSwift/MongoDatabase.swift index d5534e1b4..8427e4040 100644 --- a/Sources/MongoSwift/MongoDatabase.swift +++ b/Sources/MongoSwift/MongoDatabase.swift @@ -85,7 +85,7 @@ public class MongoDatabase { } /// The `ReadPreference` set on this database - public var readPreference: ReadPreference? { + public var readPreference: ReadPreference { return ReadPreference(from: mongoc_database_get_read_prefs(self._database)) }