@@ -18,18 +18,6 @@ class NativeConfiguration {
18
18
parsedURI . options
19
19
) ;
20
20
21
- // this.options = environment || {};
22
- // this.host = environment.host || 'localhost';
23
- // this.port = environment.port || 27017;
24
- // this.db = environment.db || 'integration_tests';
25
- // this.setName = environment.setName || 'rs';
26
-
27
- // this.topology = environment.topology || this.defaultTopology;
28
- // this.environment = environment;
29
- // if (environment.setName) {
30
- // this.replicasetName = environment.setName || 'rs';
31
- // }
32
-
33
21
this . mongo = this . require = require ( '../..' ) ;
34
22
this . writeConcern = function ( ) {
35
23
return { w : 1 } ;
@@ -52,13 +40,20 @@ class NativeConfiguration {
52
40
return this . options . db ;
53
41
}
54
42
43
+ // legacy accessors, consider for removal
44
+ get replicasetName ( ) {
45
+ return this . options . replicaSet ;
46
+ }
47
+
48
+ get setName ( ) {
49
+ return this . options . replicaSet ;
50
+ }
51
+
55
52
usingUnifiedTopology ( ) {
56
53
return ! ! process . env . MONGODB_UNIFIED_TOPOLOGY ;
57
54
}
58
55
59
56
newClient ( dbOptions , serverOptions ) {
60
- // console.trace('newClient');
61
-
62
57
if ( typeof dbOptions === 'string' ) {
63
58
return new MongoClient (
64
59
dbOptions ,
@@ -133,12 +128,18 @@ class NativeConfiguration {
133
128
}
134
129
135
130
url ( username , password ) {
131
+ const query = { } ;
132
+ if ( this . options . replicaSet ) {
133
+ Object . assign ( query , { replicaSet : this . options . replicaSet , auto_reconnect : false } ) ;
134
+ }
135
+
136
136
const urlObject = {
137
137
protocol : 'mongodb' ,
138
138
slashes : true ,
139
139
hostname : this . options . host ,
140
140
port : this . options . port ,
141
- pathname : `/${ this . options . db } `
141
+ pathname : `/${ this . options . db } ` ,
142
+ query
142
143
} ;
143
144
144
145
if ( username || password ) {
0 commit comments