mongodb 7.7.0 → 7.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/bulk/unordered.js +1 -1
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +3 -11
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +2 -0
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/collection.js +18 -119
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +110 -15
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +9 -62
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +0 -9
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +0 -9
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/cursor/list_collections_cursor.js +1 -1
- package/lib/cursor/list_collections_cursor.js.map +1 -1
- package/lib/cursor/list_indexes_cursor.js +1 -1
- package/lib/cursor/list_indexes_cursor.js.map +1 -1
- package/lib/cursor/run_command_cursor.js.map +1 -1
- package/lib/db.js +5 -58
- package/lib/db.js.map +1 -1
- package/lib/deps.js +35 -1
- package/lib/deps.js.map +1 -1
- package/lib/explain.js +0 -8
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +3 -11
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +4 -4
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +3 -18
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/mongo_client.js +2 -60
- package/lib/mongo_client.js.map +1 -1
- package/lib/operations/command.js +0 -2
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/create_collection.js +1 -1
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/indexes.js +45 -16
- package/lib/operations/indexes.js.map +1 -1
- package/lib/sdam/srv_polling.js +7 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +3 -1
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sessions.js +10 -47
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +1 -1
- package/lib/sort.js.map +1 -1
- package/lib/timeout.js +2 -11
- package/lib/timeout.js.map +1 -1
- package/lib/utils.js +84 -23
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +249 -314
- package/package.json +1 -1
- package/src/bulk/unordered.ts +1 -1
- package/src/change_stream.ts +4 -12
- package/src/client-side-encryption/client_encryption.ts +5 -32
- package/src/client-side-encryption/kms_options.ts +1 -0
- package/src/cmap/wire_protocol/compression.ts +3 -1
- package/src/collection.ts +83 -71
- package/src/connection_string.ts +135 -19
- package/src/cursor/abstract_cursor.ts +20 -97
- package/src/cursor/aggregation_cursor.ts +1 -16
- package/src/cursor/find_cursor.ts +2 -17
- package/src/cursor/list_collections_cursor.ts +1 -1
- package/src/cursor/list_indexes_cursor.ts +1 -1
- package/src/cursor/run_command_cursor.ts +4 -31
- package/src/db.ts +13 -59
- package/src/deps.ts +38 -1
- package/src/explain.ts +0 -8
- package/src/gridfs/download.ts +7 -14
- package/src/gridfs/index.ts +27 -8
- package/src/gridfs/upload.ts +6 -21
- package/src/index.ts +2 -0
- package/src/mongo_client.ts +46 -61
- package/src/operations/command.ts +1 -7
- package/src/operations/create_collection.ts +4 -2
- package/src/operations/drop.ts +1 -1
- package/src/operations/indexes.ts +213 -17
- package/src/operations/operation.ts +1 -1
- package/src/operations/run_command.ts +1 -1
- package/src/sdam/srv_polling.ts +12 -3
- package/src/sdam/topology.ts +5 -1
- package/src/sessions.ts +21 -63
- package/src/sort.ts +1 -1
- package/src/timeout.ts +2 -13
- package/src/utils.ts +96 -30
package/mongodb.d.ts
CHANGED
|
@@ -146,8 +146,11 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
146
146
|
forEach(iterator: (doc: TSchema) => boolean | void): Promise<void>;
|
|
147
147
|
/**
|
|
148
148
|
* Frees any client-side resources used by the cursor.
|
|
149
|
+
*
|
|
150
|
+
* @param _options - `timeoutMS` is deprecated and has no effect
|
|
149
151
|
*/
|
|
150
|
-
close(
|
|
152
|
+
close(_options?: {
|
|
153
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
151
154
|
timeoutMS?: number;
|
|
152
155
|
}): Promise<void>;
|
|
153
156
|
/**
|
|
@@ -295,36 +298,14 @@ export declare interface AbstractCursorOptions extends BSONSerializeOptions {
|
|
|
295
298
|
*/
|
|
296
299
|
awaitData?: boolean;
|
|
297
300
|
noCursorTimeout?: boolean;
|
|
298
|
-
/**
|
|
301
|
+
/**
|
|
302
|
+
* Specifies the time an operation will run until it throws a timeout error.
|
|
303
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
304
|
+
*/
|
|
299
305
|
timeoutMS?: number;
|
|
300
306
|
/**
|
|
301
|
-
*
|
|
302
|
-
* @
|
|
303
|
-
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
|
|
304
|
-
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
|
|
305
|
-
* `cursor.next()`.
|
|
306
|
-
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
|
|
307
|
-
*
|
|
308
|
-
* Depending on the type of cursor being used, this option has different default values.
|
|
309
|
-
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
|
|
310
|
-
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
|
|
311
|
-
* definition can have an arbitrarily long lifetime.
|
|
312
|
-
*
|
|
313
|
-
* @example
|
|
314
|
-
* ```ts
|
|
315
|
-
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
|
|
316
|
-
* for await (const doc of cursor) {
|
|
317
|
-
* // process doc
|
|
318
|
-
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
|
|
319
|
-
* // will continue to iterate successfully otherwise, regardless of the number of batches.
|
|
320
|
-
* }
|
|
321
|
-
* ```
|
|
322
|
-
*
|
|
323
|
-
* @example
|
|
324
|
-
* ```ts
|
|
325
|
-
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
|
|
326
|
-
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
|
|
327
|
-
* ```
|
|
307
|
+
* Specifies how `timeoutMS` is applied to the cursor.
|
|
308
|
+
* @deprecated `timeoutMode` has no effect and will be removed in a future release.
|
|
328
309
|
*/
|
|
329
310
|
timeoutMode?: CursorTimeoutMode;
|
|
330
311
|
/* Excluded from this release type: timeoutContext */
|
|
@@ -1891,9 +1872,7 @@ export declare class ClientEncryption {
|
|
|
1891
1872
|
* }
|
|
1892
1873
|
* ```
|
|
1893
1874
|
*/
|
|
1894
|
-
rewrapManyDataKey(filter: Filter<DataKey>, options?: ClientEncryptionRewrapManyDataKeyProviderOptions): Promise<
|
|
1895
|
-
bulkWriteResult?: BulkWriteResult;
|
|
1896
|
-
}>;
|
|
1875
|
+
rewrapManyDataKey(filter: Filter<DataKey>, options?: ClientEncryptionRewrapManyDataKeyProviderOptions): Promise<ClientEncryptionRewrapManyDataKeyResult>;
|
|
1897
1876
|
/**
|
|
1898
1877
|
* Deletes the key with the provided id from the keyvault, if it exists.
|
|
1899
1878
|
*
|
|
@@ -2101,7 +2080,7 @@ export declare interface ClientEncryptionCreateDataKeyProviderOptions {
|
|
|
2101
2080
|
* If a key is created with alternate names, then encryption may refer to the key by the unique alternate name instead of by _id.
|
|
2102
2081
|
*/
|
|
2103
2082
|
keyAltNames?: string[] | undefined;
|
|
2104
|
-
/**
|
|
2083
|
+
/** Optional 96-byte custom key material used when creating a data key instead of libmongocrypt’s random material. **/
|
|
2105
2084
|
keyMaterial?: Buffer | Binary;
|
|
2106
2085
|
/* Excluded from this release type: timeoutContext */
|
|
2107
2086
|
}
|
|
@@ -2201,42 +2180,15 @@ export declare interface ClientEncryptionOptions {
|
|
|
2201
2180
|
*/
|
|
2202
2181
|
keyExpirationMS?: number;
|
|
2203
2182
|
/**
|
|
2204
|
-
* @experimental
|
|
2205
|
-
*
|
|
2206
2183
|
* The timeout setting to be used for all the operations on ClientEncryption.
|
|
2207
|
-
*
|
|
2208
|
-
* When provided, `timeoutMS` is used as the timeout for each operation executed on
|
|
2209
|
-
* the ClientEncryption object. For example:
|
|
2210
|
-
*
|
|
2211
|
-
* ```typescript
|
|
2212
|
-
* const clientEncryption = new ClientEncryption(client, {
|
|
2213
|
-
* timeoutMS: 1_000
|
|
2214
|
-
* kmsProviders: { local: { key: '<KEY>' } }
|
|
2215
|
-
* });
|
|
2216
|
-
*
|
|
2217
|
-
* // `1_000` is used as the timeout for createDataKey call
|
|
2218
|
-
* await clientEncryption.createDataKey('local');
|
|
2219
|
-
* ```
|
|
2220
|
-
*
|
|
2221
|
-
* If `timeoutMS` is configured on the provided client, the client's `timeoutMS` value
|
|
2222
|
-
* will be used unless `timeoutMS` is also provided as a client encryption option.
|
|
2223
|
-
*
|
|
2224
|
-
* ```typescript
|
|
2225
|
-
* const client = new MongoClient('<uri>', { timeoutMS: 2_000 });
|
|
2226
|
-
*
|
|
2227
|
-
* // timeoutMS is set to 1_000 on clientEncryption
|
|
2228
|
-
* const clientEncryption = new ClientEncryption(client, {
|
|
2229
|
-
* timeoutMS: 1_000
|
|
2230
|
-
* kmsProviders: { local: { key: '<KEY>' } }
|
|
2231
|
-
* });
|
|
2232
|
-
* ```
|
|
2184
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
2233
2185
|
*/
|
|
2234
2186
|
timeoutMS?: number;
|
|
2235
2187
|
}
|
|
2236
2188
|
|
|
2237
2189
|
/**
|
|
2238
2190
|
* @public
|
|
2239
|
-
*
|
|
2191
|
+
* Options interface for `rewrapManyDataKey`; selects the new KMS provider/masterKey for bulk key rotation.
|
|
2240
2192
|
*/
|
|
2241
2193
|
export declare interface ClientEncryptionRewrapManyDataKeyProviderOptions {
|
|
2242
2194
|
provider: ClientEncryptionDataKeyProvider;
|
|
@@ -2245,7 +2197,7 @@ export declare interface ClientEncryptionRewrapManyDataKeyProviderOptions {
|
|
|
2245
2197
|
|
|
2246
2198
|
/**
|
|
2247
2199
|
* @public
|
|
2248
|
-
*
|
|
2200
|
+
* Public result shape describing the `bulkWriteResult` produced by `rewrapManyDataKey`.
|
|
2249
2201
|
*/
|
|
2250
2202
|
export declare interface ClientEncryptionRewrapManyDataKeyResult {
|
|
2251
2203
|
/** The result of rewrapping data keys. If unset, no keys matched the filter. */
|
|
@@ -2337,8 +2289,8 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2337
2289
|
/* Excluded from this release type: pinnedConnection */
|
|
2338
2290
|
/* Excluded from this release type: txnNumberIncrement */
|
|
2339
2291
|
/**
|
|
2340
|
-
* @experimental
|
|
2341
2292
|
* Specifies the time an operation in a given `ClientSession` will run until it throws a timeout error
|
|
2293
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
2342
2294
|
*/
|
|
2343
2295
|
timeoutMS?: number;
|
|
2344
2296
|
/* Excluded from this release type: timeoutContext */
|
|
@@ -2406,9 +2358,10 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2406
2358
|
/**
|
|
2407
2359
|
* Commits the currently active transaction in this session.
|
|
2408
2360
|
*
|
|
2409
|
-
* @param
|
|
2361
|
+
* @param _options - `timeoutMS` is deprecated and has no effect.
|
|
2410
2362
|
*/
|
|
2411
|
-
commitTransaction(
|
|
2363
|
+
commitTransaction(_options?: {
|
|
2364
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
2412
2365
|
timeoutMS?: number;
|
|
2413
2366
|
}): Promise<void>;
|
|
2414
2367
|
/**
|
|
@@ -2462,10 +2415,7 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2462
2415
|
withTransaction<T = any>(fn: WithTransactionCallback<T>, options?: TransactionOptions & {
|
|
2463
2416
|
/**
|
|
2464
2417
|
* Configures a timeoutMS expiry for the entire withTransactionCallback.
|
|
2465
|
-
*
|
|
2466
|
-
* @remarks
|
|
2467
|
-
* - The remaining timeout will not be applied to callback operations that do not use the ClientSession.
|
|
2468
|
-
* - Overriding timeoutMS for operations executed using the explicit session inside the provided callback will result in a client-side error.
|
|
2418
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
2469
2419
|
*/
|
|
2470
2420
|
timeoutMS?: number;
|
|
2471
2421
|
}): Promise<T>;
|
|
@@ -2486,9 +2436,8 @@ export declare interface ClientSessionOptions {
|
|
|
2486
2436
|
defaultTransactionOptions?: TransactionOptions;
|
|
2487
2437
|
/**
|
|
2488
2438
|
* @public
|
|
2489
|
-
* @experimental
|
|
2490
2439
|
* An overriding timeoutMS value to use for a client-side timeout.
|
|
2491
|
-
*
|
|
2440
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
2492
2441
|
*/
|
|
2493
2442
|
defaultTimeoutMS?: number;
|
|
2494
2443
|
/* Excluded from this release type: owner */
|
|
@@ -2689,6 +2638,7 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2689
2638
|
/** The current index hint for the collection */
|
|
2690
2639
|
get hint(): Hint | undefined;
|
|
2691
2640
|
set hint(v: Hint | undefined);
|
|
2641
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
2692
2642
|
get timeoutMS(): number | undefined;
|
|
2693
2643
|
/**
|
|
2694
2644
|
* Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field,
|
|
@@ -2828,7 +2778,7 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2828
2778
|
* Creates an index on the db and collection collection.
|
|
2829
2779
|
*
|
|
2830
2780
|
* @param indexSpec - The field name or index specification to create an index for
|
|
2831
|
-
* @param
|
|
2781
|
+
* @param indexOptions - Optional settings for the command
|
|
2832
2782
|
*
|
|
2833
2783
|
* @example
|
|
2834
2784
|
* ```ts
|
|
@@ -2851,8 +2801,22 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2851
2801
|
* // Equivalent to { j: 1, k: -1, l: 2d }
|
|
2852
2802
|
* await collection.createIndex(['j', ['k', -1], { l: '2d' }])
|
|
2853
2803
|
* ```
|
|
2804
|
+
* @deprecated Use the three parameter overload, which separates index options from
|
|
2805
|
+
* command options. This overload will be removed in a future major release.
|
|
2854
2806
|
*/
|
|
2855
2807
|
createIndex(indexSpec: IndexSpecification, options?: CreateIndexesOptions): Promise<string>;
|
|
2808
|
+
/**
|
|
2809
|
+
* Creates an index on the db and collection collection.
|
|
2810
|
+
*
|
|
2811
|
+
* Options for the index itself are given in `indexOptions`, and options for the
|
|
2812
|
+
* `createIndexes` command are given separately in `commandOptions`. Unknown fields in
|
|
2813
|
+
* `indexOptions` are passed through to the server for validation rather than being dropped.
|
|
2814
|
+
*
|
|
2815
|
+
* @param keys - The field name or index specification to create an index for
|
|
2816
|
+
* @param indexOptions - Settings for the index, or `undefined` if there are none
|
|
2817
|
+
* @param commandOptions - Settings for the `createIndexes` command, or `undefined` if there are none
|
|
2818
|
+
*/
|
|
2819
|
+
createIndex(keys: IndexSpecification, indexOptions: IndexOptions | undefined, commandOptions: CreateIndexOptions | undefined): Promise<string>;
|
|
2856
2820
|
/**
|
|
2857
2821
|
* Creates multiple indexes in the collection, this method is only supported for
|
|
2858
2822
|
* MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported
|
|
@@ -2862,7 +2826,7 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2862
2826
|
* Index specifications are defined {@link https://www.mongodb.com/docs/manual/reference/command/createIndexes/| here}.
|
|
2863
2827
|
*
|
|
2864
2828
|
* @param indexSpecs - An array of index specifications to be created
|
|
2865
|
-
* @param
|
|
2829
|
+
* @param commandOptions - Optional settings for the `createIndexes` command
|
|
2866
2830
|
*
|
|
2867
2831
|
* @example
|
|
2868
2832
|
* ```ts
|
|
@@ -2884,7 +2848,21 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2884
2848
|
* ]);
|
|
2885
2849
|
* ```
|
|
2886
2850
|
*/
|
|
2887
|
-
createIndexes(indexSpecs: IndexDescription[],
|
|
2851
|
+
createIndexes(indexSpecs: IndexDescription[], commandOptions?: CreateIndexesOptions): Promise<string[]>;
|
|
2852
|
+
/**
|
|
2853
|
+
* Creates multiple indexes in the collection, opting into "pass through" behavior for index
|
|
2854
|
+
* options the driver does not recognise.
|
|
2855
|
+
*
|
|
2856
|
+
* @param indexSpecs - An array of index specifications to be created
|
|
2857
|
+
* @param commandOptions - Optional settings for the `createIndexes` command
|
|
2858
|
+
* @param allowUnknownIndexOptions - When `true`, index options the driver does not recognise are
|
|
2859
|
+
* sent to the server instead of being dropped, for the server to validate.
|
|
2860
|
+
*
|
|
2861
|
+
* @deprecated Used to opt into "pass through" behavior, where options will be validated by the
|
|
2862
|
+
* server rather than the driver. In a future release this overload will be removed and the
|
|
2863
|
+
* default behavior will change from `false` to `true`.
|
|
2864
|
+
*/
|
|
2865
|
+
createIndexes(indexSpecs: IndexDescription[], commandOptions: CreateIndexesOptions | undefined, allowUnknownIndexOptions: boolean): Promise<string[]>;
|
|
2888
2866
|
/**
|
|
2889
2867
|
* Drops an index from this collection.
|
|
2890
2868
|
*
|
|
@@ -3087,60 +3065,6 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
3087
3065
|
* expectType<Schema>(change.fullDocument);
|
|
3088
3066
|
* });
|
|
3089
3067
|
* ```
|
|
3090
|
-
*
|
|
3091
|
-
* @remarks
|
|
3092
|
-
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
|
|
3093
|
-
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
|
|
3094
|
-
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
|
|
3095
|
-
* event.
|
|
3096
|
-
*
|
|
3097
|
-
* Note that if a change stream is consistently timing out when watching a collection, database or
|
|
3098
|
-
* client that is being changed, then this may be due to the server timing out before it can finish
|
|
3099
|
-
* processing the existing oplog. To address this, restart the change stream with a higher
|
|
3100
|
-
* `timeoutMS`.
|
|
3101
|
-
*
|
|
3102
|
-
* If the change stream times out the initial aggregate operation to establish the change stream on
|
|
3103
|
-
* the server, then the client will close the change stream. If the getMore calls to the server
|
|
3104
|
-
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
|
|
3105
|
-
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
|
|
3106
|
-
* emitter mode.
|
|
3107
|
-
*
|
|
3108
|
-
* To determine whether or not the change stream is still open following a timeout, check the
|
|
3109
|
-
* {@link ChangeStream.closed} getter.
|
|
3110
|
-
*
|
|
3111
|
-
* @example
|
|
3112
|
-
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
|
|
3113
|
-
* The next call can just be retried after this succeeds.
|
|
3114
|
-
* ```ts
|
|
3115
|
-
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
3116
|
-
* try {
|
|
3117
|
-
* await changeStream.next();
|
|
3118
|
-
* } catch (e) {
|
|
3119
|
-
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
3120
|
-
* await changeStream.next();
|
|
3121
|
-
* }
|
|
3122
|
-
* throw e;
|
|
3123
|
-
* }
|
|
3124
|
-
* ```
|
|
3125
|
-
*
|
|
3126
|
-
* @example
|
|
3127
|
-
* In emitter mode, if the change stream goes `timeoutMS` without emitting a change event, it will
|
|
3128
|
-
* emit an error event that returns a MongoOperationTimeoutError, but will not close the change
|
|
3129
|
-
* stream unless the resume attempt fails. There is no need to re-establish change listeners as
|
|
3130
|
-
* this will automatically continue emitting change events once the resume attempt completes.
|
|
3131
|
-
*
|
|
3132
|
-
* ```ts
|
|
3133
|
-
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
3134
|
-
* changeStream.on('change', console.log);
|
|
3135
|
-
* changeStream.on('error', e => {
|
|
3136
|
-
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
3137
|
-
* // do nothing
|
|
3138
|
-
* } else {
|
|
3139
|
-
* changeStream.close();
|
|
3140
|
-
* }
|
|
3141
|
-
* });
|
|
3142
|
-
* ```
|
|
3143
|
-
*
|
|
3144
3068
|
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
|
|
3145
3069
|
* @param options - Optional settings for the command
|
|
3146
3070
|
* @typeParam TLocal - Type of the data being detected by the change stream
|
|
@@ -3252,8 +3176,8 @@ export declare interface CollectionOptions extends BSONSerializeOptions, WriteCo
|
|
|
3252
3176
|
/** The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). */
|
|
3253
3177
|
readPreference?: ReadPreferenceLike;
|
|
3254
3178
|
/**
|
|
3255
|
-
* @experimental
|
|
3256
3179
|
* Specifies the time an operation will run until it throws a timeout error
|
|
3180
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
3257
3181
|
*/
|
|
3258
3182
|
timeoutMS?: number;
|
|
3259
3183
|
}
|
|
@@ -3708,7 +3632,7 @@ export declare interface CreateCollectionOptions extends Omit<CommandOperationOp
|
|
|
3708
3632
|
clusteredIndex?: ClusteredCollectionOptions;
|
|
3709
3633
|
/** The number of seconds after which a document in a timeseries or clustered collection expires. */
|
|
3710
3634
|
expireAfterSeconds?: number;
|
|
3711
|
-
/**
|
|
3635
|
+
/** Queryable Encryption field schema attached at collection creation. **/
|
|
3712
3636
|
encryptedFields?: Document;
|
|
3713
3637
|
/**
|
|
3714
3638
|
* If set, enables pre-update and post-update document events to be included for any
|
|
@@ -3753,6 +3677,27 @@ export declare interface CreateIndexesOptions extends Omit<CommandOperationOptio
|
|
|
3753
3677
|
wildcardProjection?: Document;
|
|
3754
3678
|
/** Specifies that the index should exist on the target collection but should not be used by the query planner when executing operations. */
|
|
3755
3679
|
hidden?: boolean;
|
|
3680
|
+
/** Collation */
|
|
3681
|
+
collation?: CollationOptions;
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
/** @public */
|
|
3685
|
+
export declare interface CreateIndexOptions extends Omit<CommandOperationOptions, 'collation' | 'explain'> {
|
|
3686
|
+
/**
|
|
3687
|
+
* Specifies how many data-bearing members of a replica set, including the primary, must
|
|
3688
|
+
* complete the index builds successfully before the primary marks the indexes as ready.
|
|
3689
|
+
*
|
|
3690
|
+
* This option accepts the same values for the "w" field in a write concern plus "votingMembers",
|
|
3691
|
+
* which indicates all voting data-bearing nodes.
|
|
3692
|
+
*
|
|
3693
|
+
* This option is only supported by servers \>= 4.4. Drivers MUST manually raise an error if this option
|
|
3694
|
+
* is specified when creating an index on a pre 4.4 server. See the Q&A section for the rationale behind this.
|
|
3695
|
+
*
|
|
3696
|
+
* @remarks This option is sent only if the caller explicitly provides a value. The default is to not send a value.
|
|
3697
|
+
*
|
|
3698
|
+
* @sinceServerVersion 4.4
|
|
3699
|
+
*/
|
|
3700
|
+
commitQuorum?: number | string;
|
|
3756
3701
|
}
|
|
3757
3702
|
|
|
3758
3703
|
/**
|
|
@@ -3789,32 +3734,8 @@ export declare type CursorFlag = (typeof CURSOR_FLAGS)[number];
|
|
|
3789
3734
|
|
|
3790
3735
|
/**
|
|
3791
3736
|
* @public
|
|
3792
|
-
*
|
|
3793
|
-
*
|
|
3794
|
-
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
|
|
3795
|
-
* `cursor.next()`.
|
|
3796
|
-
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
|
|
3797
|
-
*
|
|
3798
|
-
* Depending on the type of cursor being used, this option has different default values.
|
|
3799
|
-
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
|
|
3800
|
-
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
|
|
3801
|
-
* definition can have an arbitrarily long lifetime.
|
|
3802
|
-
*
|
|
3803
|
-
* @example
|
|
3804
|
-
* ```ts
|
|
3805
|
-
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
|
|
3806
|
-
* for await (const doc of cursor) {
|
|
3807
|
-
* // process doc
|
|
3808
|
-
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
|
|
3809
|
-
* // will continue to iterate successfully otherwise, regardless of the number of batches.
|
|
3810
|
-
* }
|
|
3811
|
-
* ```
|
|
3812
|
-
*
|
|
3813
|
-
* @example
|
|
3814
|
-
* ```ts
|
|
3815
|
-
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
|
|
3816
|
-
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
|
|
3817
|
-
* ```
|
|
3737
|
+
* Specifies how `timeoutMS` is applied to the cursor.
|
|
3738
|
+
* @deprecated `timeoutMode` has no effect and will be removed in a future release.
|
|
3818
3739
|
*/
|
|
3819
3740
|
export declare const CursorTimeoutMode: Readonly<{
|
|
3820
3741
|
readonly ITERATION: "iteration";
|
|
@@ -3823,7 +3744,7 @@ export declare const CursorTimeoutMode: Readonly<{
|
|
|
3823
3744
|
|
|
3824
3745
|
/**
|
|
3825
3746
|
* @public
|
|
3826
|
-
* @
|
|
3747
|
+
* @deprecated `timeoutMode` has no effect and will be removed in a future release.
|
|
3827
3748
|
*/
|
|
3828
3749
|
export declare type CursorTimeoutMode = (typeof CursorTimeoutMode)[keyof typeof CursorTimeoutMode];
|
|
3829
3750
|
|
|
@@ -3902,6 +3823,7 @@ export declare class Db {
|
|
|
3902
3823
|
get bsonOptions(): BSONSerializeOptions;
|
|
3903
3824
|
get writeConcern(): WriteConcern | undefined;
|
|
3904
3825
|
get namespace(): string;
|
|
3826
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
3905
3827
|
get timeoutMS(): number | undefined;
|
|
3906
3828
|
/**
|
|
3907
3829
|
* Create a new collection on a server with the specified options. Use this to create capped collections.
|
|
@@ -4057,59 +3979,6 @@ export declare class Db {
|
|
|
4057
3979
|
* watch() accepts two generic arguments for distinct use cases:
|
|
4058
3980
|
* - The first is to provide the schema that may be defined for all the collections within this database
|
|
4059
3981
|
* - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
|
|
4060
|
-
*
|
|
4061
|
-
* @remarks
|
|
4062
|
-
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
|
|
4063
|
-
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
|
|
4064
|
-
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
|
|
4065
|
-
* event.
|
|
4066
|
-
*
|
|
4067
|
-
* Note that if a change stream is consistently timing out when watching a collection, database or
|
|
4068
|
-
* client that is being changed, then this may be due to the server timing out before it can finish
|
|
4069
|
-
* processing the existing oplog. To address this, restart the change stream with a higher
|
|
4070
|
-
* `timeoutMS`.
|
|
4071
|
-
*
|
|
4072
|
-
* If the change stream times out the initial aggregate operation to establish the change stream on
|
|
4073
|
-
* the server, then the client will close the change stream. If the getMore calls to the server
|
|
4074
|
-
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
|
|
4075
|
-
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
|
|
4076
|
-
* emitter mode.
|
|
4077
|
-
*
|
|
4078
|
-
* To determine whether or not the change stream is still open following a timeout, check the
|
|
4079
|
-
* {@link ChangeStream.closed} getter.
|
|
4080
|
-
*
|
|
4081
|
-
* @example
|
|
4082
|
-
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
|
|
4083
|
-
* The next call can just be retried after this succeeds.
|
|
4084
|
-
* ```ts
|
|
4085
|
-
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
4086
|
-
* try {
|
|
4087
|
-
* await changeStream.next();
|
|
4088
|
-
* } catch (e) {
|
|
4089
|
-
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
4090
|
-
* await changeStream.next();
|
|
4091
|
-
* }
|
|
4092
|
-
* throw e;
|
|
4093
|
-
* }
|
|
4094
|
-
* ```
|
|
4095
|
-
*
|
|
4096
|
-
* @example
|
|
4097
|
-
* In emitter mode, if the change stream goes `timeoutMS` without emitting a change event, it will
|
|
4098
|
-
* emit an error event that returns a MongoOperationTimeoutError, but will not close the change
|
|
4099
|
-
* stream unless the resume attempt fails. There is no need to re-establish change listeners as
|
|
4100
|
-
* this will automatically continue emitting change events once the resume attempt completes.
|
|
4101
|
-
*
|
|
4102
|
-
* ```ts
|
|
4103
|
-
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
4104
|
-
* changeStream.on('change', console.log);
|
|
4105
|
-
* changeStream.on('error', e => {
|
|
4106
|
-
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
4107
|
-
* // do nothing
|
|
4108
|
-
* } else {
|
|
4109
|
-
* changeStream.close();
|
|
4110
|
-
* }
|
|
4111
|
-
* });
|
|
4112
|
-
* ```
|
|
4113
3982
|
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
|
|
4114
3983
|
* @param options - Optional settings for the command
|
|
4115
3984
|
* @typeParam TSchema - Type of the data being detected by the change stream
|
|
@@ -4145,8 +4014,8 @@ export declare interface DbOptions extends BSONSerializeOptions, WriteConcernOpt
|
|
|
4145
4014
|
/** Should retry failed writes */
|
|
4146
4015
|
retryWrites?: boolean;
|
|
4147
4016
|
/**
|
|
4148
|
-
* @experimental
|
|
4149
4017
|
* Specifies the time an operation will run until it throws a timeout error
|
|
4018
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
4150
4019
|
*/
|
|
4151
4020
|
timeoutMS?: number;
|
|
4152
4021
|
}
|
|
@@ -4246,7 +4115,7 @@ export declare interface DriverInfo {
|
|
|
4246
4115
|
|
|
4247
4116
|
/** @public */
|
|
4248
4117
|
export declare interface DropCollectionOptions extends Omit<CommandOperationOptions, 'rawData'> {
|
|
4249
|
-
/**
|
|
4118
|
+
/** Queryable Encryption field schema used during collection drop so associated state collections are dropped too. **/
|
|
4250
4119
|
encryptedFields?: Document;
|
|
4251
4120
|
}
|
|
4252
4121
|
|
|
@@ -4265,7 +4134,10 @@ export declare interface EndSessionOptions {
|
|
|
4265
4134
|
/* Excluded from this release type: error */
|
|
4266
4135
|
force?: boolean;
|
|
4267
4136
|
forceClear?: boolean;
|
|
4268
|
-
/**
|
|
4137
|
+
/**
|
|
4138
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
4139
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
4140
|
+
*/
|
|
4269
4141
|
timeoutMS?: number;
|
|
4270
4142
|
}
|
|
4271
4143
|
|
|
@@ -4854,7 +4726,8 @@ export declare class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents>
|
|
|
4854
4726
|
* @param id - The id of the file doc
|
|
4855
4727
|
*/
|
|
4856
4728
|
delete(id: ObjectId, options?: {
|
|
4857
|
-
timeoutMS
|
|
4729
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
4730
|
+
timeoutMS?: number;
|
|
4858
4731
|
}): Promise<void>;
|
|
4859
4732
|
/** Convenience wrapper around find on the files collection */
|
|
4860
4733
|
find(filter?: Filter<GridFSFile>, options?: FindOptions): FindCursor<GridFSFile>;
|
|
@@ -4873,11 +4746,13 @@ export declare class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents>
|
|
|
4873
4746
|
* @param filename - new name for the file
|
|
4874
4747
|
*/
|
|
4875
4748
|
rename(id: ObjectId, filename: string, options?: {
|
|
4876
|
-
timeoutMS
|
|
4749
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
4750
|
+
timeoutMS?: number;
|
|
4877
4751
|
}): Promise<void>;
|
|
4878
4752
|
/** Removes this bucket's files collection, followed by its chunks collection. */
|
|
4879
4753
|
drop(options?: {
|
|
4880
|
-
timeoutMS
|
|
4754
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
4755
|
+
timeoutMS?: number;
|
|
4881
4756
|
}): Promise<void>;
|
|
4882
4757
|
}
|
|
4883
4758
|
|
|
@@ -4895,9 +4770,9 @@ export declare interface GridFSBucketOptions extends WriteConcernOptions {
|
|
|
4895
4770
|
/** Read preference to be passed to read operations */
|
|
4896
4771
|
readPreference?: ReadPreference;
|
|
4897
4772
|
/**
|
|
4898
|
-
* @experimental
|
|
4899
4773
|
* Specifies the lifetime duration of a gridFS stream. If any async operations are in progress
|
|
4900
4774
|
* when this timeout expires, the stream will throw a timeout error.
|
|
4775
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
4901
4776
|
*/
|
|
4902
4777
|
timeoutMS?: number;
|
|
4903
4778
|
}
|
|
@@ -4957,8 +4832,8 @@ export declare interface GridFSBucketReadStreamOptions {
|
|
|
4957
4832
|
*/
|
|
4958
4833
|
end?: number;
|
|
4959
4834
|
/**
|
|
4960
|
-
* @experimental
|
|
4961
4835
|
* Specifies the time an operation will run until it throws a timeout error
|
|
4836
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
4962
4837
|
*/
|
|
4963
4838
|
timeoutMS?: number;
|
|
4964
4839
|
}
|
|
@@ -5052,8 +4927,8 @@ export declare interface GridFSBucketWriteStreamOptions extends WriteConcernOpti
|
|
|
5052
4927
|
/** Object to store in the file document's `metadata` field */
|
|
5053
4928
|
metadata?: Document;
|
|
5054
4929
|
/**
|
|
5055
|
-
* @experimental
|
|
5056
4930
|
* Specifies the time an operation will run until it throws a timeout error
|
|
4931
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
5057
4932
|
*/
|
|
5058
4933
|
timeoutMS?: number;
|
|
5059
4934
|
}
|
|
@@ -5148,7 +5023,11 @@ export declare interface IdPServerResponse {
|
|
|
5148
5023
|
refreshToken?: string;
|
|
5149
5024
|
}
|
|
5150
5025
|
|
|
5151
|
-
/**
|
|
5026
|
+
/**
|
|
5027
|
+
* @public
|
|
5028
|
+
*
|
|
5029
|
+
* Loosely aligns with `IndexModel` from the spec.
|
|
5030
|
+
* */
|
|
5152
5031
|
export declare interface IndexDescription extends Pick<CreateIndexesOptions, 'background' | 'unique' | 'partialFilterExpression' | 'sparse' | 'hidden' | 'expireAfterSeconds' | 'storageEngine' | 'version' | 'weights' | 'default_language' | 'language_override' | 'textIndexVersion' | '2dsphereIndexVersion' | 'bits' | 'min' | 'max' | 'bucketSize' | 'wildcardProjection'> {
|
|
5153
5032
|
collation?: CollationOptions;
|
|
5154
5033
|
name?: string;
|
|
@@ -5197,6 +5076,103 @@ export declare interface IndexInformationOptions extends ListIndexesOptions {
|
|
|
5197
5076
|
full?: boolean;
|
|
5198
5077
|
}
|
|
5199
5078
|
|
|
5079
|
+
/** @public */
|
|
5080
|
+
export declare interface IndexOptions extends Document {
|
|
5081
|
+
/**
|
|
5082
|
+
* Optionally specifies the length in time, in seconds, for documents to remain in
|
|
5083
|
+
* a collection.
|
|
5084
|
+
*/
|
|
5085
|
+
expireAfterSeconds?: number;
|
|
5086
|
+
/**
|
|
5087
|
+
* Optionally specify a specific name for the index outside of the default generated
|
|
5088
|
+
* name. If none is provided then the name is generated in the format "[field]_[direction]".
|
|
5089
|
+
*
|
|
5090
|
+
* Note that if an index is created for the same key pattern with different collations,
|
|
5091
|
+
* a name must be provided by the user to avoid ambiguity.
|
|
5092
|
+
*
|
|
5093
|
+
* @example For an index of name: 1, age: -1, the generated name would be "name_1_age_-1".
|
|
5094
|
+
*/
|
|
5095
|
+
name?: string;
|
|
5096
|
+
/**
|
|
5097
|
+
* Optionally tells the index to only reference documents with the specified field in
|
|
5098
|
+
* the index.
|
|
5099
|
+
*/
|
|
5100
|
+
sparse?: boolean;
|
|
5101
|
+
/**
|
|
5102
|
+
* Optionally allows users to configure the storage engine on a per-index basis when creating
|
|
5103
|
+
* an index.
|
|
5104
|
+
*/
|
|
5105
|
+
storageEngine?: Document;
|
|
5106
|
+
/**
|
|
5107
|
+
* Optionally forces the index to be unique.
|
|
5108
|
+
*/
|
|
5109
|
+
unique?: boolean;
|
|
5110
|
+
/**
|
|
5111
|
+
* Optionally specifies the index version number, either 0 or 1.
|
|
5112
|
+
*/
|
|
5113
|
+
version?: number;
|
|
5114
|
+
/**
|
|
5115
|
+
* Optionally specifies the default language for text indexes.
|
|
5116
|
+
* Is 'english' if none is provided.
|
|
5117
|
+
*/
|
|
5118
|
+
defaultLanguage?: string;
|
|
5119
|
+
/**
|
|
5120
|
+
* Optionally Specifies the field in the document to override the language.
|
|
5121
|
+
*/
|
|
5122
|
+
languageOverride?: string;
|
|
5123
|
+
/**
|
|
5124
|
+
* Optionally provides the text index version number.
|
|
5125
|
+
*/
|
|
5126
|
+
textIndexVersion?: number;
|
|
5127
|
+
/**
|
|
5128
|
+
* Optionally specifies fields in the index and their corresponding weight values.
|
|
5129
|
+
*/
|
|
5130
|
+
weights?: Document;
|
|
5131
|
+
/**
|
|
5132
|
+
* Optionally specifies the 2dsphere index version number.
|
|
5133
|
+
*/
|
|
5134
|
+
'2dsphereIndexVersion'?: number;
|
|
5135
|
+
/**
|
|
5136
|
+
* Optionally specifies the precision of the stored geo hash in the 2d index, from 1 to 32.
|
|
5137
|
+
*/
|
|
5138
|
+
bits?: number;
|
|
5139
|
+
/**
|
|
5140
|
+
* Optionally sets the maximum boundary for latitude and longitude in the 2d index.
|
|
5141
|
+
*/
|
|
5142
|
+
max?: number;
|
|
5143
|
+
/**
|
|
5144
|
+
* Optionally sets the minimum boundary for latitude and longitude in the index in a
|
|
5145
|
+
* 2d index.
|
|
5146
|
+
*/
|
|
5147
|
+
min?: number;
|
|
5148
|
+
/**
|
|
5149
|
+
* Optionally specifies the number of units within which to group the location values
|
|
5150
|
+
* in a geo haystack index.
|
|
5151
|
+
*/
|
|
5152
|
+
bucketSize?: number;
|
|
5153
|
+
/**
|
|
5154
|
+
* Optionally specifies a filter for use in a partial index. Only documents that match the
|
|
5155
|
+
* filter expression are included in the index.
|
|
5156
|
+
*/
|
|
5157
|
+
partialFilterExpression?: Document;
|
|
5158
|
+
/**
|
|
5159
|
+
* Optionally specifies a collation to use for the index. If not specified, no collation is
|
|
5160
|
+
* sent and the default collation of the collection server-side is used.
|
|
5161
|
+
*/
|
|
5162
|
+
collation?: CollationOptions;
|
|
5163
|
+
/**
|
|
5164
|
+
* Optionally specifies the wildcard projection of a wildcard index.
|
|
5165
|
+
*/
|
|
5166
|
+
wildcardProjection?: Document;
|
|
5167
|
+
/**
|
|
5168
|
+
* Optionally specifies that the index should exist on the target collection but should not be used by the query
|
|
5169
|
+
* planner when executing operations.
|
|
5170
|
+
*
|
|
5171
|
+
* This option is only supported by servers \>= 4.4.
|
|
5172
|
+
*/
|
|
5173
|
+
hidden?: boolean;
|
|
5174
|
+
}
|
|
5175
|
+
|
|
5200
5176
|
/** @public */
|
|
5201
5177
|
export declare type IndexSpecification = OneOrMore<string | [string, IndexDirection] | {
|
|
5202
5178
|
[key: string]: IndexDirection;
|
|
@@ -5356,6 +5332,7 @@ export declare interface KMIPKMSProviderConfiguration {
|
|
|
5356
5332
|
export declare type KMSConnectCallback = (options: {
|
|
5357
5333
|
host: string;
|
|
5358
5334
|
port: number;
|
|
5335
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
5359
5336
|
timeoutMS?: number;
|
|
5360
5337
|
signal: AbortSignal;
|
|
5361
5338
|
}) => Promise<Duplex>;
|
|
@@ -5773,6 +5750,7 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
|
|
|
5773
5750
|
get writeConcern(): WriteConcern | undefined;
|
|
5774
5751
|
get readPreference(): ReadPreference;
|
|
5775
5752
|
get bsonOptions(): BSONSerializeOptions;
|
|
5753
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
5776
5754
|
get timeoutMS(): number | undefined;
|
|
5777
5755
|
/**
|
|
5778
5756
|
* Executes a client bulk write operation, available on server 8.0+.
|
|
@@ -5871,12 +5849,6 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
|
|
|
5871
5849
|
* **Connection Pooling Impact:** Calling `connect` will populate the connection pool with one connection
|
|
5872
5850
|
* to a server selected by the client's configured `readPreference` (defaults to primary).
|
|
5873
5851
|
*
|
|
5874
|
-
* @remarks
|
|
5875
|
-
* **Timeout Behavior:** When using `timeoutMS`, the connection establishment time does not count against
|
|
5876
|
-
* the timeout for subsequent operations. This means `connect` runs without a `timeoutMS` limit, while
|
|
5877
|
-
* your database operations will still respect the configured timeout. If you need predictable operation
|
|
5878
|
-
* timing with `timeoutMS`, call `connect` explicitly before performing operations.
|
|
5879
|
-
*
|
|
5880
5852
|
* @see https://www.mongodb.com/docs/manual/reference/connection-string/
|
|
5881
5853
|
*/
|
|
5882
5854
|
static connect(url: string, options?: MongoClientOptions): Promise<MongoClient>;
|
|
@@ -5907,59 +5879,6 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
|
|
|
5907
5879
|
* watch() accepts two generic arguments for distinct use cases:
|
|
5908
5880
|
* - The first is to provide the schema that may be defined for all the data within the current cluster
|
|
5909
5881
|
* - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
|
|
5910
|
-
*
|
|
5911
|
-
* @remarks
|
|
5912
|
-
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
|
|
5913
|
-
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
|
|
5914
|
-
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
|
|
5915
|
-
* event.
|
|
5916
|
-
*
|
|
5917
|
-
* Note that if a change stream is consistently timing out when watching a collection, database or
|
|
5918
|
-
* client that is being changed, then this may be due to the server timing out before it can finish
|
|
5919
|
-
* processing the existing oplog. To address this, restart the change stream with a higher
|
|
5920
|
-
* `timeoutMS`.
|
|
5921
|
-
*
|
|
5922
|
-
* If the change stream times out the initial aggregate operation to establish the change stream on
|
|
5923
|
-
* the server, then the client will close the change stream. If the getMore calls to the server
|
|
5924
|
-
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
|
|
5925
|
-
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
|
|
5926
|
-
* emitter mode.
|
|
5927
|
-
*
|
|
5928
|
-
* To determine whether or not the change stream is still open following a timeout, check the
|
|
5929
|
-
* {@link ChangeStream.closed} getter.
|
|
5930
|
-
*
|
|
5931
|
-
* @example
|
|
5932
|
-
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
|
|
5933
|
-
* The next call can just be retried after this succeeds.
|
|
5934
|
-
* ```ts
|
|
5935
|
-
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
5936
|
-
* try {
|
|
5937
|
-
* await changeStream.next();
|
|
5938
|
-
* } catch (e) {
|
|
5939
|
-
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
5940
|
-
* await changeStream.next();
|
|
5941
|
-
* }
|
|
5942
|
-
* throw e;
|
|
5943
|
-
* }
|
|
5944
|
-
* ```
|
|
5945
|
-
*
|
|
5946
|
-
* @example
|
|
5947
|
-
* In emitter mode, if the change stream goes `timeoutMS` without emitting a change event, it will
|
|
5948
|
-
* emit an error event that returns a MongoOperationTimeoutError, but will not close the change
|
|
5949
|
-
* stream unless the resume attempt fails. There is no need to re-establish change listeners as
|
|
5950
|
-
* this will automatically continue emitting change events once the resume attempt completes.
|
|
5951
|
-
*
|
|
5952
|
-
* ```ts
|
|
5953
|
-
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
5954
|
-
* changeStream.on('change', console.log);
|
|
5955
|
-
* changeStream.on('error', e => {
|
|
5956
|
-
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
5957
|
-
* // do nothing
|
|
5958
|
-
* } else {
|
|
5959
|
-
* changeStream.close();
|
|
5960
|
-
* }
|
|
5961
|
-
* });
|
|
5962
|
-
* ```
|
|
5963
5882
|
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
|
|
5964
5883
|
* @param options - Optional settings for the command
|
|
5965
5884
|
* @typeParam TSchema - Type of the data being detected by the change stream
|
|
@@ -6081,8 +6000,8 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
6081
6000
|
/** Specifies the name of the replica set, if the mongod is a member of a replica set. */
|
|
6082
6001
|
replicaSet?: string;
|
|
6083
6002
|
/**
|
|
6084
|
-
* @experimental
|
|
6085
6003
|
* Specifies the time an operation will run until it throws a timeout error
|
|
6004
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
6086
6005
|
*/
|
|
6087
6006
|
timeoutMS?: number;
|
|
6088
6007
|
/** Enables or disables TLS/SSL for the connection. */
|
|
@@ -6121,6 +6040,46 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
6121
6040
|
* Querying this DNS URI is expected to respond with SRV records
|
|
6122
6041
|
*/
|
|
6123
6042
|
srvServiceName?: string;
|
|
6043
|
+
/**
|
|
6044
|
+
* A host name suffix that every host returned by the SRV lookup must end with. It replaces the
|
|
6045
|
+
* default verification, which requires returned hosts to share the parent domain of the SRV host
|
|
6046
|
+
* name (the SRV host name without its leftmost label). Only valid with a `mongodb+srv` connection
|
|
6047
|
+
* string, and cannot be combined with `srvHostValidator`.
|
|
6048
|
+
*
|
|
6049
|
+
* For example, with `mongodb+srv://cluster.mongodb.mydomain.net`, the default verification
|
|
6050
|
+
* rejects `host1.us-east-1.mydomain.net`, while `srvAllowedHostsSuffix: '.mydomain.net'` accepts
|
|
6051
|
+
* it. A leading `.` is optional. Internationalized domain names may be given in Unicode or in
|
|
6052
|
+
* A-label (`xn--`) form: the value is converted to lowercase A-label form, and a value that cannot
|
|
6053
|
+
* be converted is an error. The value must contain at least two labels, unless it is one of the
|
|
6054
|
+
* names reserved for private or special use: `test`, `localhost`, `invalid`, `example`, `local`,
|
|
6055
|
+
* `internal`, `corp`, `home`, or `mail`.
|
|
6056
|
+
*
|
|
6057
|
+
* **WARNING: Modifying the default SRV domain name validation can create vulnerabilities.**
|
|
6058
|
+
* SRV host verification prevents a spoofed DNS response from directing the driver to arbitrary
|
|
6059
|
+
* hosts, and this option widens the set of hosts such a response can direct it to. Configure the
|
|
6060
|
+
* narrowest suffix that covers your deployment: for a seed of
|
|
6061
|
+
* `cluster.test.internal.example.com`, prefer `.internal.example.com` over `.example.com`.
|
|
6062
|
+
*/
|
|
6063
|
+
srvAllowedHostsSuffix?: string;
|
|
6064
|
+
/**
|
|
6065
|
+
* A synchronous function that decides whether a host returned by the SRV lookup may be used. It
|
|
6066
|
+
* receives the host name, normalized to lowercase A-label (Punycode) form without a trailing `.`,
|
|
6067
|
+
* and must return `true` to accept the host or `false` to reject it. Its return value replaces the
|
|
6068
|
+
* default verification entirely: the driver applies no other checks to the host. Only valid with a
|
|
6069
|
+
* `mongodb+srv` connection string, cannot be combined with `srvAllowedHostsSuffix`, and cannot be
|
|
6070
|
+
* set in the connection string.
|
|
6071
|
+
*
|
|
6072
|
+
* The function runs synchronously during SRV resolution and SRV polling, so it must not block.
|
|
6073
|
+
*
|
|
6074
|
+
* If the function throws during the initial SRV lookup, `connect()` rejects with a
|
|
6075
|
+
* `MongoAPIError` whose `cause` is the thrown error. During SRV polling, the host is rejected
|
|
6076
|
+
* instead and no error is raised.
|
|
6077
|
+
*
|
|
6078
|
+
* **WARNING: Modifying the default SRV domain name validation can create vulnerabilities.**
|
|
6079
|
+
* SRV host verification prevents a spoofed DNS response from directing the driver to arbitrary
|
|
6080
|
+
* hosts, and a validator that accepts too broadly removes that protection.
|
|
6081
|
+
*/
|
|
6082
|
+
srvHostValidator?: (host: string) => boolean;
|
|
6124
6083
|
/** The maximum number of connections in the connection pool. */
|
|
6125
6084
|
maxPoolSize?: number;
|
|
6126
6085
|
/** The minimum number of connections in the connection pool. */
|
|
@@ -7031,6 +6990,8 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
|
|
|
7031
6990
|
appName?: string;
|
|
7032
6991
|
hosts: HostAddress[];
|
|
7033
6992
|
srvHost?: string;
|
|
6993
|
+
srvAllowedHostsSuffix?: string;
|
|
6994
|
+
srvHostValidator?: (host: string) => boolean;
|
|
7034
6995
|
credentials?: MongoCredentials;
|
|
7035
6996
|
readPreference: ReadPreference;
|
|
7036
6997
|
readConcern: ReadConcern;
|
|
@@ -7094,6 +7055,7 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
|
|
|
7094
7055
|
tlsCertificateKeyFile?: string;
|
|
7095
7056
|
/* Excluded from this release type: mongoLoggerOptions */
|
|
7096
7057
|
/* Excluded from this release type: mongodbLogPath */
|
|
7058
|
+
/** @deprecated `timeoutMS` has no effect and will be removed in a future release. */
|
|
7097
7059
|
timeoutMS?: number;
|
|
7098
7060
|
/* Excluded from this release type: __skipPingOnConnect */
|
|
7099
7061
|
/* Excluded from this release type: runtime */
|
|
@@ -7539,8 +7501,8 @@ export declare interface OperationOptions extends BSONSerializeOptions {
|
|
|
7539
7501
|
/* Excluded from this release type: bypassPinningCheck */
|
|
7540
7502
|
/* Excluded from this release type: omitMaxTimeMS */
|
|
7541
7503
|
/**
|
|
7542
|
-
* @experimental
|
|
7543
7504
|
* Specifies the time an operation will run until it throws a timeout error
|
|
7505
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
7544
7506
|
*/
|
|
7545
7507
|
timeoutMS?: number;
|
|
7546
7508
|
}
|
|
@@ -7960,8 +7922,8 @@ export declare type RunCommandOptions = {
|
|
|
7960
7922
|
/** The read preference */
|
|
7961
7923
|
readPreference?: ReadPreferenceLike;
|
|
7962
7924
|
/**
|
|
7963
|
-
* @experimental
|
|
7964
7925
|
* Specifies the time an operation will run until it throws a timeout error
|
|
7926
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
7965
7927
|
*/
|
|
7966
7928
|
timeoutMS?: number;
|
|
7967
7929
|
/* Excluded from this release type: omitMaxTimeMS */
|
|
@@ -7973,40 +7935,13 @@ export declare type RunCursorCommandOptions = {
|
|
|
7973
7935
|
readPreference?: ReadPreferenceLike;
|
|
7974
7936
|
session?: ClientSession;
|
|
7975
7937
|
/**
|
|
7976
|
-
*
|
|
7977
|
-
*
|
|
7978
|
-
* `maxTimeMS` is provided in the command in addition to setting `timeoutMS` in the options, then
|
|
7979
|
-
* the original value of `maxTimeMS` will be overwritten.
|
|
7938
|
+
* Specifies the time an operation will run until it throws a timeout error.
|
|
7939
|
+
* @deprecated `timeoutMS` has no effect and will be removed in a future release.
|
|
7980
7940
|
*/
|
|
7981
7941
|
timeoutMS?: number;
|
|
7982
7942
|
/**
|
|
7983
|
-
*
|
|
7984
|
-
* @
|
|
7985
|
-
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
|
|
7986
|
-
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
|
|
7987
|
-
* `cursor.next()`.
|
|
7988
|
-
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
|
|
7989
|
-
*
|
|
7990
|
-
* Depending on the type of cursor being used, this option has different default values.
|
|
7991
|
-
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
|
|
7992
|
-
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
|
|
7993
|
-
* definition can have an arbitrarily long lifetime.
|
|
7994
|
-
*
|
|
7995
|
-
* @example
|
|
7996
|
-
* ```ts
|
|
7997
|
-
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
|
|
7998
|
-
* for await (const doc of cursor) {
|
|
7999
|
-
* // process doc
|
|
8000
|
-
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
|
|
8001
|
-
* // will continue to iterate successfully otherwise, regardless of the number of batches.
|
|
8002
|
-
* }
|
|
8003
|
-
* ```
|
|
8004
|
-
*
|
|
8005
|
-
* @example
|
|
8006
|
-
* ```ts
|
|
8007
|
-
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
|
|
8008
|
-
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
|
|
8009
|
-
* ```
|
|
7943
|
+
* Specifies how `timeoutMS` is applied to the cursor.
|
|
7944
|
+
* @deprecated `timeoutMode` has no effect and will be removed in a future release.
|
|
8010
7945
|
*/
|
|
8011
7946
|
timeoutMode?: CursorTimeoutMode;
|
|
8012
7947
|
tailable?: boolean;
|