File tree 4 files changed +18
-6
lines changed
4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,16 @@ export class Collection {
278
278
options ?: InsertOneOptions | Callback < InsertOneResult > ,
279
279
callback ?: Callback < InsertOneResult >
280
280
) : Promise < InsertOneResult > | void {
281
- if ( typeof options === 'function' ) ( callback = options ) , ( options = { } ) ;
281
+ if ( typeof options === 'function' ) {
282
+ callback = options ;
283
+ options = { } ;
284
+ }
285
+
286
+ // CSFLE passes in { w: 'majority' } to ensure the lib works in both 3.x and 4.x
287
+ // we support that option style here only
288
+ if ( options && Reflect . get ( options , 'w' ) ) {
289
+ options . writeConcern = WriteConcern . fromOptions ( Reflect . get ( options , 'w' ) ) ;
290
+ }
282
291
283
292
return executeOperation (
284
293
getTopology ( this ) ,
Original file line number Diff line number Diff line change @@ -418,7 +418,7 @@ export function parseOptions(
418
418
419
419
checkTLSOptions ( mongoOptions ) ;
420
420
if ( mongoClient && options . autoEncryption ) {
421
- mongoOptions . autoEncrypter = createAutoEncrypter ( mongoClient , options ) ;
421
+ mongoOptions . autoEncrypter = createAutoEncrypter ( mongoClient , mongoOptions ) ;
422
422
}
423
423
if ( options . promiseLibrary ) PromiseProvider . set ( options . promiseLibrary ) ;
424
424
@@ -1062,7 +1062,10 @@ export const OPTIONS = {
1062
1062
passphrase : { type : 'any' } ,
1063
1063
pfx : { type : 'any' } ,
1064
1064
secureProtocol : { type : 'any' } ,
1065
- index : { type : 'any' }
1065
+ index : { type : 'any' } ,
1066
+ // Legacy Options, these are unused but left here to avoid errors with CSFLE lib
1067
+ useNewUrlParser : { type : 'boolean' } as OptionDescriptor ,
1068
+ useUnifiedTopology : { type : 'boolean' } as OptionDescriptor
1066
1069
} as Record < keyof MongoClientOptions , OptionDescriptor > ;
1067
1070
1068
1071
export const DEFAULT_OPTIONS = new CaseInsensitiveMap (
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { resolveSRVRecord } from '../connection_string';
4
4
import { emitDeprecationWarning , Callback } from '../utils' ;
5
5
import { CMAP_EVENT_NAMES } from '../cmap/events' ;
6
6
import * as BSON from '../bson' ;
7
- import type { MongoClient , MongoOptions , MongoClientOptions } from '../mongo_client' ;
7
+ import type { MongoClient , MongoOptions } from '../mongo_client' ;
8
8
import { Connection } from '../cmap/connection' ;
9
9
import { Server } from '../sdam/server' ;
10
10
import type { AutoEncrypter } from '../deps' ;
@@ -116,7 +116,7 @@ function registerDeprecatedEventNotifiers(client: MongoClient) {
116
116
*/
117
117
export function createAutoEncrypter (
118
118
client : MongoClient ,
119
- options : MongoClientOptions
119
+ options : MongoOptions
120
120
) : AutoEncrypter | undefined {
121
121
if ( ! options . autoEncryption ) {
122
122
return ;
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ class TestConfiguration {
185
185
} else {
186
186
multipleHosts = this . options . hostAddresses
187
187
. reduce ( ( built , host ) => {
188
- built . push ( host . type === 'tcp ' ? `${ host . host } :${ host . port } ` : host . host ) ;
188
+ built . push ( typeof host . port === 'number ' ? `${ host . host } :${ host . port } ` : host . host ) ;
189
189
return built ;
190
190
} , [ ] )
191
191
. join ( ',' ) ;
You can’t perform that action at this time.
0 commit comments