@@ -74,7 +74,6 @@ interface FindAndModifyOptions extends CommandOperationOptions {
74
74
75
75
// NOTE: These types are a misuse of options, can we think of a way to remove them?
76
76
remove ?: boolean ;
77
- new ?: boolean ;
78
77
}
79
78
80
79
/** @internal */
@@ -121,9 +120,15 @@ export class FindAndModifyOperation extends CommandOperation<Document> {
121
120
cmd . sort = sort ;
122
121
}
123
122
124
- cmd . new = options . new ? true : false ;
123
+ if ( ! options . remove ) {
124
+ cmd . new = typeof options . returnOriginal === 'boolean' ? ! options . returnOriginal : false ;
125
+ cmd . upsert = typeof options . upsert === 'boolean' ? options . upsert : false ;
126
+ if ( doc ) {
127
+ cmd . update = doc ;
128
+ }
129
+ }
130
+
125
131
cmd . remove = options . remove ? true : false ;
126
- cmd . upsert = options . upsert ? true : false ;
127
132
128
133
if ( options . projection ) {
129
134
cmd . fields = options . projection ;
@@ -133,10 +138,6 @@ export class FindAndModifyOperation extends CommandOperation<Document> {
133
138
cmd . arrayFilters = options . arrayFilters ;
134
139
}
135
140
136
- if ( doc && ! options . remove ) {
137
- cmd . update = doc ;
138
- }
139
-
140
141
if ( options . maxTimeMS ) {
141
142
cmd . maxTimeMS = options . maxTimeMS ;
142
143
}
@@ -212,8 +213,6 @@ export class FindOneAndReplaceOperation extends FindAndModifyOperation {
212
213
) {
213
214
// Final options
214
215
const finalOptions = Object . assign ( { } , options ) ;
215
- finalOptions . new = options . returnOriginal !== void 0 ? ! options . returnOriginal : false ;
216
- finalOptions . upsert = options . upsert !== void 0 ? ! ! options . upsert : false ;
217
216
218
217
if ( filter == null || typeof filter !== 'object' ) {
219
218
throw new TypeError ( 'Filter parameter must be an object' ) ;
@@ -241,9 +240,6 @@ export class FindOneAndUpdateOperation extends FindAndModifyOperation {
241
240
) {
242
241
// Final options
243
242
const finalOptions = Object . assign ( { } , options ) ;
244
- finalOptions . new =
245
- typeof options . returnOriginal === 'boolean' ? ! options . returnOriginal : false ;
246
- finalOptions . upsert = typeof options . upsert === 'boolean' ? options . upsert : false ;
247
243
248
244
if ( filter == null || typeof filter !== 'object' ) {
249
245
throw new TypeError ( 'Filter parameter must be an object' ) ;
0 commit comments