/
MongoConnectionOptions.ts
324 lines (262 loc) · 8.63 KB
/
MongoConnectionOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
import {BaseConnectionOptions} from "../../connection/BaseConnectionOptions";
import {ReadPreference} from "./typings";
/**
* MongoDB specific connection options.
* Synced with http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html
*/
export interface MongoConnectionOptions extends BaseConnectionOptions {
/**
* Database type.
*/
readonly type: "mongodb";
/**
* Connection url where perform connection to.
*/
readonly url?: string;
/**
* Database host.
*/
readonly host?: string;
/**
* Database host port.
*/
readonly port?: number;
/**
* Database username.
*/
readonly username?: string;
/**
* Database password.
*/
readonly password?: string;
/**
* Database name to connect to.
*/
readonly database?: string;
/**
* Set the maximum poolSize for each individual server or proxy connection.
*/
readonly poolSize?: number;
/**
* Use ssl connection (needs to have a mongod server with ssl support). Default: false
*/
readonly ssl?: boolean;
/**
* Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher).
* Default: true
*/
readonly sslValidate?: boolean;
/**
* Array of valid certificates either as Buffers or Strings
* (needs to have a mongod server with ssl support, 2.4 or higher).
*/
readonly sslCA?: string[]|Buffer[];
/**
* String or buffer containing the certificate we wish to present
* (needs to have a mongod server with ssl support, 2.4 or higher)
*/
readonly sslCert?: string|Buffer;
/**
* String or buffer containing the certificate private key we wish to present
* (needs to have a mongod server with ssl support, 2.4 or higher)
*/
readonly sslKey?: string;
/**
* String or buffer containing the certificate password
* (needs to have a mongod server with ssl support, 2.4 or higher)
*/
readonly sslPass?: string|Buffer;
/**
* SSL Certificate revocation list binary buffer
* (needs to have a mongod server with ssl support, 2.4 or higher)
*/
readonly sslCRL?: string|Buffer;
/**
* Reconnect on error. Default: true
*/
readonly autoReconnect?: boolean;
/**
* TCP Socket NoDelay option. Default: true
*/
readonly noDelay?: boolean;
/**
* The number of milliseconds to wait before initiating keepAlive on the TCP socket. Default: 30000
*/
readonly keepAlive?: number;
/**
* TCP Connection timeout setting. Default: 30000
*/
readonly connectTimeoutMS?: number;
/**
* Version of IP stack. Can be 4, 6.
* If undefined, will attempt to connect with IPv6, and will fall back to IPv4 on failure
*/
readonly family?: number;
/**
* TCP Socket timeout setting. Default: 360000
*/
readonly socketTimeoutMS?: number;
/**
* Server attempt to reconnect #times. Default 30
*/
readonly reconnectTries?: number;
/**
* Server will wait #milliseconds between retries. Default 1000
*/
readonly reconnectInterval?: number;
/**
* Control if high availability monitoring runs for Replicaset or Mongos proxies. Default true
*/
readonly ha?: boolean;
/**
* The High availability period for replicaset inquiry. Default: 10000
*/
readonly haInterval?: number;
/**
* The name of the replicaset to connect to
*/
readonly replicaSet?: string;
/**
* Sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms).
* Default: 15
*/
readonly acceptableLatencyMS?: number;
/**
* Sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms).
* Default: 15
*/
readonly secondaryAcceptableLatencyMS?: number;
/**
* Sets if the driver should connect even if no primary is available. Default: false
*/
readonly connectWithNoPrimary?: boolean;
/**
* If the database authentication is dependent on another databaseName.
*/
readonly authSource?: string;
/**
* The write concern.
*/
readonly w?: string|number;
/**
* The write concern timeout value.
*/
readonly wtimeout?: number;
/**
* Specify a journal write concern. Default: false
*/
readonly j?: boolean;
/**
* Force server to assign _id values instead of driver. Default: false
*/
readonly forceServerObjectId?: boolean;
/**
* Serialize functions on any object. Default: false
*/
readonly serializeFunctions?: boolean;
/**
* Specify if the BSON serializer should ignore undefined fields. Default: false
*/
readonly ignoreUndefined?: boolean;
/**
* Return document results as raw BSON buffers. Default: false
*/
readonly raw?: boolean;
/**
* Promotes Long values to number if they fit inside the 53 bits resolution. Default: true
*/
readonly promoteLongs?: boolean;
/**
* Promotes Binary BSON values to native Node Buffers. Default: false
*/
readonly promoteBuffers?: boolean;
/**
* Promotes BSON values to native types where possible, set to false to only receive wrapper types. Default: true
*/
readonly promoteValues?: boolean;
/**
* Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. Default: false
*/
readonly domainsEnabled?: boolean;
/**
* Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection,
* default is -1 which is unlimited.
*/
readonly bufferMaxEntries?: number;
/**
* The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY,
* ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
*/
readonly readPreference?: ReadPreference|string;
/**
* A primary key factory object for generation of custom _id keys.
*/
readonly pkFactory?: any;
/**
* A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible.
*/
readonly promiseLibrary?: any;
/**
* Specify a read concern for the collection. (only MongoDB 3.2 or higher supported).
*/
readonly readConcern?: any;
/**
* Specify a maxStalenessSeconds value for secondary reads, minimum is 90 seconds
*/
readonly maxStalenessSeconds?: number;
/**
* Specify the log level used by the driver logger (error/warn/info/debug).
*/
readonly loggerLevel?: "error"|"warn"|"info"|"debug";
// Do not overwrite BaseConnectionOptions.logger
// readonly logger?: any;
/**
* Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function
* Default: true
*/
readonly checkServerIdentity?: boolean|Function;
/**
* Validate MongoClient passed in options for correctness. Default: false
*/
readonly validateOptions?: boolean|any;
/**
* The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections
*/
readonly appname?: string;
/**
* Sets the authentication mechanism that MongoDB will use to authenticate the connection
*/
readonly authMechanism?: string;
/**
* Type of compression to use: snappy or zlib
*/
readonly compression?: any;
/**
* Specify a file sync write concern. Default: false
*/
readonly fsync?: boolean;
/**
* Read preference tags
*/
readonly readPreferenceTags?: any[];
/**
* The number of retries for a tailable cursor. Default: 5
*/
readonly numberOfRetries?: number;
/**
* Enable auto reconnecting for single server instances. Default: true
*/
readonly auto_reconnect?: boolean;
/**
* Enable command monitoring for this client. Default: false
*/
readonly monitorCommands?: boolean;
/**
* If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections
*/
readonly minSize?: number;
/**
* Determines whether or not to use the new url parser. Default: false
*/
readonly useNewUrlParser?: boolean;
}