@@ -9,10 +9,10 @@ extension MongoCollection {
9
9
* - filter: `Document` representing the match criteria
10
10
* - options: Optional `FindOneAndDeleteOptions` to use when executing the command
11
11
*
12
- * - Returns: The deleted document, or `nil` if no document was deleted.
12
+ * - Returns: The deleted document, represented as a `CollectionType`, or `nil` if no document was deleted.
13
13
*/
14
14
@discardableResult
15
- public func findOneAndDelete( _ filter: Document , options: FindOneAndDeleteOptions ? = nil ) throws -> Document ? {
15
+ public func findOneAndDelete( _ filter: Document , options: FindOneAndDeleteOptions ? = nil ) throws -> CollectionType ? {
16
16
throw MongoError . commandError ( message: " Unimplemented command " )
17
17
}
18
18
@@ -21,15 +21,15 @@ extension MongoCollection {
21
21
*
22
22
* - Parameters:
23
23
* - filter: `Document` representing the match criteria
24
- * - replacement: a `Document ` to replace the found one
24
+ * - replacement: a `CollectionType ` to replace the found document
25
25
* - options: Optional `FindOneAndReplaceOptions` to use when executing the command
26
26
*
27
- * - Returns: Either the original document or its replacement depending on selected options,
28
- * or `nil` if there was no match.
27
+ * - Returns: A `CollectionType`, representing either the original document or its replacement,
28
+ * depending on selected options, or `nil` if there was no match.
29
29
*/
30
30
@discardableResult
31
- public func findOneAndReplace( filter: Document , replacement: Document ,
32
- options: FindOneAndDeleteOptions ? = nil ) throws -> Document ? {
31
+ public func findOneAndReplace( filter: Document , replacement: T ,
32
+ options: FindOneAndDeleteOptions ? = nil ) throws -> CollectionType ? {
33
33
throw MongoError . commandError ( message: " Unimplemented command " )
34
34
}
35
35
@@ -38,7 +38,7 @@ extension MongoCollection {
38
38
*
39
39
* - Parameters:
40
40
* - filter: `Document` representing the match criteria
41
- * - replacement : a `Document` to replace the found one
41
+ * - update : a `Document` containing updates to apply
42
42
* - options: Optional `FindOneAndUpdateOptions` to use when executing the command
43
43
*
44
44
* - Returns: Either the original or updated document depending on selected options,
@@ -52,16 +52,20 @@ extension MongoCollection {
52
52
}
53
53
54
54
/// Indicates which document to return in a find and modify operation.
55
- public enum ReturnDocument {
55
+ public enum ReturnDocument : Encodable {
56
56
/// Indicates to return the document before the update, replacement, or insert occured.
57
57
case before
58
58
59
59
/// Indicates to return the document after the update, replacement, or insert occured.
60
60
case after
61
+
62
+ public func encode( to encoder: Encoder ) throws {
63
+ // fill in later on
64
+ }
61
65
}
62
66
63
67
/// Options to use when executing a `findOneAndDelete` command on a `MongoCollection`.
64
- public struct FindOneAndDeleteOptions {
68
+ public struct FindOneAndDeleteOptions : Encodable {
65
69
/// Specifies a collation to use.
66
70
public let collation : Document ?
67
71
@@ -73,10 +77,13 @@ public struct FindOneAndDeleteOptions {
73
77
74
78
/// Determines which document the operation modifies if the query selects multiple documents.
75
79
public let sort : Document ?
80
+
81
+ /// An optional `WriteConcern` to use for the command.
82
+ public let writeConcern : WriteConcern ?
76
83
}
77
84
78
85
/// Options to use when executing a `findOneAndReplace` command on a `MongoCollection`.
79
- public struct FindOneAndReplaceOptions {
86
+ public struct FindOneAndReplaceOptions : Encodable {
80
87
/// If `true`, allows the write to opt-out of document level validation.
81
88
public let bypassDocumentValidation : Bool ?
82
89
@@ -97,10 +104,13 @@ public struct FindOneAndReplaceOptions {
97
104
98
105
/// When `true`, creates a new document if no document matches the query.
99
106
public let upsert : Bool ?
107
+
108
+ /// An optional `WriteConcern` to use for the command.
109
+ public let writeConcern : WriteConcern ?
100
110
}
101
111
102
112
/// Options to use when executing a `findOneAndUpdate` command on a `MongoCollection`.
103
- public struct FindOneAndUpdateOptions {
113
+ public struct FindOneAndUpdateOptions : Encodable {
104
114
/// A set of filters specifying to which array elements an update should apply.
105
115
public let arrayFilters : [ Document ] ?
106
116
@@ -124,4 +134,7 @@ public struct FindOneAndUpdateOptions {
124
134
125
135
/// When `true`, creates a new document if no document matches the query.
126
136
public let upsert : Bool ?
137
+
138
+ /// An optional `WriteConcern` to use for the command.
139
+ public let writeConcern : WriteConcern ?
127
140
}
0 commit comments