mongodb 4.0.0 → 4.1.2
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 +62 -30
- package/lib/bson.js +1 -0
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +53 -30
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js +3 -2
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js +3 -2
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +23 -13
- package/lib/change_stream.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js +2 -1
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +5 -4
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +9 -5
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongocr.js +2 -2
- package/lib/cmap/auth/mongocr.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +32 -32
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/plain.js +1 -1
- package/lib/cmap/auth/plain.js.map +1 -1
- package/lib/cmap/auth/scram.js +15 -12
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js +2 -2
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js +26 -10
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +9 -5
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +23 -9
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +43 -46
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +113 -15
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js +3 -1
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/cmap/errors.js +3 -3
- package/lib/cmap/errors.js.map +1 -1
- package/lib/cmap/message_stream.js +1 -1
- package/lib/cmap/message_stream.js.map +1 -1
- package/lib/cmap/metrics.js +62 -0
- package/lib/cmap/metrics.js.map +1 -0
- package/lib/cmap/stream_description.js +3 -1
- package/lib/cmap/stream_description.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +22 -9
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +1 -1
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js +23 -18
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +76 -30
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +75 -68
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +47 -9
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +53 -13
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +21 -14
- package/lib/db.js.map +1 -1
- package/lib/deps.js +16 -5
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js +5 -8
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +230 -34
- package/lib/error.js.map +1 -1
- package/lib/explain.js +2 -2
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +22 -47
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +4 -3
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +13 -21
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +27 -2
- package/lib/index.js.map +1 -1
- package/lib/logger.js +3 -2
- package/lib/logger.js.map +1 -1
- package/lib/mongo_client.js +5 -8
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/add_user.js +2 -3
- package/lib/operations/add_user.js.map +1 -1
- package/lib/operations/aggregate.js +12 -9
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/command.js +5 -7
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/common_functions.js +1 -1
- package/lib/operations/common_functions.js.map +1 -1
- package/lib/operations/connect.js +3 -2
- package/lib/operations/connect.js.map +1 -1
- package/lib/operations/count.js +1 -1
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/count_documents.js +1 -1
- package/lib/operations/count_documents.js.map +1 -1
- package/lib/operations/delete.js +5 -5
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js +2 -2
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/estimated_document_count.js +5 -1
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/eval.js.map +1 -1
- package/lib/operations/execute_operation.js +31 -17
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +13 -9
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +9 -9
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/indexes.js +8 -3
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +5 -3
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/is_capped.js +2 -1
- package/lib/operations/is_capped.js.map +1 -1
- package/lib/operations/list_collections.js +6 -3
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/map_reduce.js +1 -1
- package/lib/operations/map_reduce.js.map +1 -1
- package/lib/operations/operation.js +3 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/options_operation.js +2 -1
- package/lib/operations/options_operation.js.map +1 -1
- package/lib/operations/profiling_level.js +4 -2
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/set_profiling_level.js +4 -2
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/update.js +12 -12
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js +6 -5
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/promise_provider.js +1 -1
- package/lib/promise_provider.js.map +1 -1
- package/lib/read_preference.js +8 -8
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/common.js +12 -10
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/server.js +90 -25
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +9 -4
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +10 -4
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +1 -1
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +42 -21
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js +7 -3
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +132 -31
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +3 -3
- package/lib/sort.js.map +1 -1
- package/lib/transactions.js +15 -7
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +60 -20
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +523 -138
- package/mongodb.ts34.d.ts +480 -141
- package/package.json +44 -48
- package/src/bson.ts +1 -0
- package/src/bulk/common.ts +83 -43
- package/src/bulk/ordered.ts +4 -3
- package/src/bulk/unordered.ts +4 -3
- package/src/change_stream.ts +46 -29
- package/src/cmap/auth/auth_provider.ts +3 -2
- package/src/cmap/auth/gssapi.ts +15 -5
- package/src/cmap/auth/mongo_credentials.ts +22 -8
- package/src/cmap/auth/mongocr.ts +3 -3
- package/src/cmap/auth/mongodb_aws.ts +52 -39
- package/src/cmap/auth/plain.ts +2 -2
- package/src/cmap/auth/scram.ts +23 -13
- package/src/cmap/auth/x509.ts +3 -3
- package/src/cmap/command_monitoring_events.ts +36 -14
- package/src/cmap/commands.ts +12 -6
- package/src/cmap/connect.ts +42 -12
- package/src/cmap/connection.ts +54 -62
- package/src/cmap/connection_pool.ts +141 -20
- package/src/cmap/connection_pool_events.ts +8 -1
- package/src/cmap/errors.ts +3 -4
- package/src/cmap/message_stream.ts +2 -4
- package/src/cmap/metrics.ts +58 -0
- package/src/cmap/stream_description.ts +6 -1
- package/src/cmap/wire_protocol/compression.ts +26 -13
- package/src/cmap/wire_protocol/shared.ts +4 -2
- package/src/collection.ts +75 -70
- package/src/connection_string.ts +97 -34
- package/src/cursor/abstract_cursor.ts +141 -104
- package/src/cursor/aggregation_cursor.ts +34 -20
- package/src/cursor/find_cursor.ts +41 -21
- package/src/db.ts +19 -18
- package/src/deps.ts +110 -22
- package/src/encrypter.ts +6 -12
- package/src/error.ts +264 -48
- package/src/explain.ts +3 -3
- package/src/gridfs/download.ts +48 -53
- package/src/gridfs/index.ts +5 -4
- package/src/gridfs/upload.ts +32 -33
- package/src/index.ts +42 -4
- package/src/logger.ts +6 -3
- package/src/mongo_client.ts +20 -23
- package/src/mongo_types.ts +19 -20
- package/src/operations/add_user.ts +4 -5
- package/src/operations/aggregate.ts +18 -17
- package/src/operations/command.ts +7 -10
- package/src/operations/common_functions.ts +2 -3
- package/src/operations/connect.ts +4 -3
- package/src/operations/count.ts +2 -2
- package/src/operations/count_documents.ts +2 -2
- package/src/operations/delete.ts +8 -6
- package/src/operations/distinct.ts +5 -3
- package/src/operations/estimated_document_count.ts +5 -1
- package/src/operations/eval.ts +1 -1
- package/src/operations/execute_operation.ts +41 -20
- package/src/operations/find.ts +25 -16
- package/src/operations/find_and_modify.ts +12 -10
- package/src/operations/indexes.ts +39 -8
- package/src/operations/insert.ts +7 -4
- package/src/operations/is_capped.ts +3 -2
- package/src/operations/list_collections.ts +9 -6
- package/src/operations/map_reduce.ts +4 -2
- package/src/operations/operation.ts +7 -2
- package/src/operations/options_operation.ts +3 -2
- package/src/operations/profiling_level.ts +5 -3
- package/src/operations/set_profiling_level.ts +9 -3
- package/src/operations/update.ts +17 -13
- package/src/operations/validate_collection.ts +7 -6
- package/src/promise_provider.ts +2 -2
- package/src/read_preference.ts +11 -9
- package/src/sdam/common.ts +11 -9
- package/src/sdam/server.ts +168 -69
- package/src/sdam/server_description.ts +16 -4
- package/src/sdam/server_selection.ts +15 -7
- package/src/sdam/srv_polling.ts +2 -2
- package/src/sdam/topology.ts +67 -36
- package/src/sdam/topology_description.ts +11 -4
- package/src/sessions.ts +194 -37
- package/src/sort.ts +6 -4
- package/src/transactions.ts +18 -9
- package/src/utils.ts +73 -20
- package/HISTORY.md +0 -2993
- package/lib/operations/find_one.js +0 -34
- package/lib/operations/find_one.js.map +0 -1
- package/src/operations/find_one.ts +0 -43
package/mongodb.ts34.d.ts
CHANGED
|
@@ -57,33 +57,41 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
57
57
|
Excluded from this release type: cursorOptions */
|
|
58
58
|
readonly closed: boolean;
|
|
59
59
|
readonly killed: boolean;
|
|
60
|
+
readonly loadBalanced: boolean;
|
|
60
61
|
/** Returns current buffered documents length */
|
|
61
62
|
bufferedCount(): number;
|
|
62
63
|
/** Returns current buffered documents */
|
|
63
64
|
readBufferedDocuments(number?: number): TSchema[];
|
|
64
|
-
[Symbol.asyncIterator](): AsyncIterator<TSchema
|
|
65
|
+
[Symbol.asyncIterator](): AsyncIterator<TSchema, void>;
|
|
65
66
|
stream(options?: CursorStreamOptions): Readable;
|
|
66
67
|
hasNext(): Promise<boolean>;
|
|
67
68
|
hasNext(callback: Callback<boolean>): void;
|
|
68
69
|
/** Get the next available document from the cursor, returns null if no more documents are available. */
|
|
69
|
-
next
|
|
70
|
-
next
|
|
70
|
+
next(): Promise<TSchema | null>;
|
|
71
|
+
next(callback: Callback<TSchema | null>): void;
|
|
72
|
+
next(callback?: Callback<TSchema | null>): Promise<TSchema | null> | void;
|
|
71
73
|
/**
|
|
72
74
|
* Try to get the next available document from the cursor or `null` if an empty batch is returned
|
|
73
75
|
*/
|
|
74
|
-
tryNext
|
|
75
|
-
tryNext
|
|
76
|
+
tryNext(): Promise<TSchema | null>;
|
|
77
|
+
tryNext(callback: Callback<TSchema | null>): void;
|
|
76
78
|
/**
|
|
77
79
|
* Iterates over all the documents for this cursor using the iterator, callback pattern.
|
|
78
80
|
*
|
|
79
81
|
* @param iterator - The iteration callback.
|
|
80
82
|
* @param callback - The end callback.
|
|
81
83
|
*/
|
|
82
|
-
forEach
|
|
83
|
-
forEach
|
|
84
|
+
forEach(iterator: (doc: TSchema) => boolean | void): Promise<void>;
|
|
85
|
+
forEach(iterator: (doc: TSchema) => boolean | void, callback: Callback<void>): void;
|
|
84
86
|
close(): void;
|
|
85
87
|
close(callback: Callback): void;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated options argument is deprecated
|
|
90
|
+
*/
|
|
86
91
|
close(options: CursorCloseOptions): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated options argument is deprecated
|
|
94
|
+
*/
|
|
87
95
|
close(options: CursorCloseOptions, callback: Callback): void;
|
|
88
96
|
/**
|
|
89
97
|
* Returns an array of documents. The caller is responsible for making sure that there
|
|
@@ -93,8 +101,8 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
93
101
|
*
|
|
94
102
|
* @param callback - The result callback.
|
|
95
103
|
*/
|
|
96
|
-
toArray
|
|
97
|
-
toArray
|
|
104
|
+
toArray(): Promise<TSchema[]>;
|
|
105
|
+
toArray(callback: Callback<TSchema[]>): void;
|
|
98
106
|
/**
|
|
99
107
|
* Add a cursor flag to the cursor
|
|
100
108
|
*
|
|
@@ -106,11 +114,12 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
106
114
|
* Map all documents using the provided function
|
|
107
115
|
* If there is a transform set on the cursor, that will be called first and the result passed to
|
|
108
116
|
* this function's transform.
|
|
109
|
-
* @remarks
|
|
110
117
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
|
|
120
|
+
* it **does not** return a new instance of a cursor. This means when calling map,
|
|
121
|
+
* you should always assign the result to a new variable in order to get a correctly typed cursor variable.
|
|
122
|
+
* Take note of the following example:
|
|
114
123
|
*
|
|
115
124
|
* @example
|
|
116
125
|
* ```typescript
|
|
@@ -365,8 +374,7 @@ export declare interface AggregateOptions extends CommandOperationOptions {
|
|
|
365
374
|
* @public
|
|
366
375
|
*/
|
|
367
376
|
export declare class AggregationCursor<TSchema = Document> extends AbstractCursor<TSchema> {
|
|
368
|
-
/*Excluded from this release type: [
|
|
369
|
-
Excluded from this release type: [kPipeline]
|
|
377
|
+
/*Excluded from this release type: [kPipeline]
|
|
370
378
|
Excluded from this release type: [kOptions]
|
|
371
379
|
Excluded from this release type: __constructor */
|
|
372
380
|
readonly pipeline: Document[];
|
|
@@ -383,8 +391,11 @@ export declare class AggregationCursor<TSchema = Document> extends AbstractCurso
|
|
|
383
391
|
limit($limit: number): this;
|
|
384
392
|
/** Add a match stage to the aggregation pipeline */
|
|
385
393
|
match($match: Document): this;
|
|
386
|
-
/** Add
|
|
387
|
-
out($out:
|
|
394
|
+
/** Add an out stage to the aggregation pipeline */
|
|
395
|
+
out($out: {
|
|
396
|
+
db: string;
|
|
397
|
+
coll: string;
|
|
398
|
+
} | string): this;
|
|
388
399
|
/**
|
|
389
400
|
* Add a project stage to the aggregation pipeline
|
|
390
401
|
*
|
|
@@ -392,18 +403,41 @@ export declare class AggregationCursor<TSchema = Document> extends AbstractCurso
|
|
|
392
403
|
* In order to strictly type this function you must provide an interface
|
|
393
404
|
* that represents the effect of your projection on the result documents.
|
|
394
405
|
*
|
|
395
|
-
*
|
|
406
|
+
* By default chaining a projection to your cursor changes the returned type to the generic {@link Document} type.
|
|
407
|
+
* You should specify a parameterized type to have assertions on your final results.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```typescript
|
|
411
|
+
* // Best way
|
|
412
|
+
* const docs: AggregationCursor<{ a: number }> = cursor.project<{ a: number }>({ _id: 0, a: true });
|
|
413
|
+
* // Flexible way
|
|
414
|
+
* const docs: AggregationCursor<Document> = cursor.project({ _id: 0, a: true });
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* @remarks
|
|
418
|
+
* In order to strictly type this function you must provide an interface
|
|
419
|
+
* that represents the effect of your projection on the result documents.
|
|
420
|
+
*
|
|
421
|
+
* **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
|
|
396
422
|
* it **does not** return a new instance of a cursor. This means when calling project,
|
|
397
|
-
* you should always assign the result to a new variable
|
|
423
|
+
* you should always assign the result to a new variable in order to get a correctly typed cursor variable.
|
|
424
|
+
* Take note of the following example:
|
|
398
425
|
*
|
|
399
426
|
* @example
|
|
400
427
|
* ```typescript
|
|
401
428
|
* const cursor: AggregationCursor<{ a: number; b: string }> = coll.aggregate([]);
|
|
402
|
-
* const projectCursor = cursor.project<{ a: number }>({ a: true });
|
|
429
|
+
* const projectCursor = cursor.project<{ a: number }>({ _id: 0, a: true });
|
|
403
430
|
* const aPropOnlyArray: {a: number}[] = await projectCursor.toArray();
|
|
431
|
+
*
|
|
432
|
+
* // or always use chaining and save the final cursor
|
|
433
|
+
*
|
|
434
|
+
* const cursor = coll.aggregate().project<{ a: string }>({
|
|
435
|
+
* _id: 0,
|
|
436
|
+
* a: { $convert: { input: '$a', to: 'string' }
|
|
437
|
+
* }});
|
|
404
438
|
* ```
|
|
405
439
|
*/
|
|
406
|
-
project<T =
|
|
440
|
+
project<T extends Document = Document>($project: Document): AggregationCursor<T>;
|
|
407
441
|
/** Add a lookup stage to the aggregation pipeline */
|
|
408
442
|
lookup($lookup: Document): this;
|
|
409
443
|
/** Add a redact stage to the aggregation pipeline */
|
|
@@ -471,6 +505,13 @@ export declare const AuthMechanism: Readonly<{
|
|
|
471
505
|
/** @public */
|
|
472
506
|
export declare type AuthMechanism = typeof AuthMechanism[keyof typeof AuthMechanism];
|
|
473
507
|
/** @public */
|
|
508
|
+
export declare interface AuthMechanismProperties extends Document {
|
|
509
|
+
SERVICE_NAME?: string;
|
|
510
|
+
SERVICE_REALM?: string;
|
|
511
|
+
CANONICALIZE_HOST_NAME?: boolean;
|
|
512
|
+
AWS_SESSION_TOKEN?: string;
|
|
513
|
+
}
|
|
514
|
+
/** @public */
|
|
474
515
|
export declare interface AutoEncrypter {
|
|
475
516
|
new (client: MongoClient, options: AutoEncryptionOptions): AutoEncrypter;
|
|
476
517
|
init(cb: Callback): void;
|
|
@@ -602,7 +643,7 @@ export declare const BatchType: Readonly<{
|
|
|
602
643
|
export declare type BatchType = typeof BatchType[keyof typeof BatchType];
|
|
603
644
|
export { Binary };
|
|
604
645
|
/** @public */
|
|
605
|
-
export declare type BitwiseFilter = number /** numeric bit mask */ | Binary /** BinData bit mask */ | number
|
|
646
|
+
export declare type BitwiseFilter = number /** numeric bit mask */ | Binary /** BinData bit mask */ | ReadonlyArray<number>;
|
|
606
647
|
export { BSONRegExp };
|
|
607
648
|
/**
|
|
608
649
|
* BSON Serialization options.
|
|
@@ -730,6 +771,7 @@ export declare interface BulkWriteOperationError {
|
|
|
730
771
|
index: number;
|
|
731
772
|
code: number;
|
|
732
773
|
errmsg: string;
|
|
774
|
+
errInfo: Document;
|
|
733
775
|
op: Document | UpdateStatement | DeleteStatement;
|
|
734
776
|
}
|
|
735
777
|
/** @public */
|
|
@@ -1009,12 +1051,18 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
1009
1051
|
/*Excluded from this release type: [kServerSession]
|
|
1010
1052
|
Excluded from this release type: [kSnapshotTime]
|
|
1011
1053
|
Excluded from this release type: [kSnapshotEnabled]
|
|
1054
|
+
Excluded from this release type: [kPinnedConnection]
|
|
1012
1055
|
Excluded from this release type: __constructor
|
|
1013
1056
|
The server id associated with this session */
|
|
1014
1057
|
readonly id: ServerSessionId | undefined;
|
|
1015
1058
|
readonly serverSession: ServerSession;
|
|
1016
1059
|
/*Whether or not this session is configured for snapshot reads */
|
|
1017
1060
|
readonly snapshotEnabled: boolean;
|
|
1061
|
+
readonly loadBalanced: boolean;
|
|
1062
|
+
/*Excluded from this release type: pinnedConnection
|
|
1063
|
+
Excluded from this release type: pin
|
|
1064
|
+
Excluded from this release type: unpin */
|
|
1065
|
+
readonly isPinned: boolean;
|
|
1018
1066
|
/**
|
|
1019
1067
|
* Ends this session on the server
|
|
1020
1068
|
*
|
|
@@ -1023,14 +1071,20 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
1023
1071
|
*/
|
|
1024
1072
|
endSession(): Promise<void>;
|
|
1025
1073
|
endSession(callback: Callback<void>): void;
|
|
1026
|
-
endSession(options:
|
|
1027
|
-
endSession(options:
|
|
1074
|
+
endSession(options: EndSessionOptions): Promise<void>;
|
|
1075
|
+
endSession(options: EndSessionOptions, callback: Callback<void>): void;
|
|
1028
1076
|
/**
|
|
1029
1077
|
* Advances the operationTime for a ClientSession.
|
|
1030
1078
|
*
|
|
1031
1079
|
* @param operationTime - the `BSON.Timestamp` of the operation type it is desired to advance to
|
|
1032
1080
|
*/
|
|
1033
1081
|
advanceOperationTime(operationTime: Timestamp): void;
|
|
1082
|
+
/**
|
|
1083
|
+
* Advances the clusterTime for a ClientSession to the provided clusterTime of another ClientSession
|
|
1084
|
+
*
|
|
1085
|
+
* @param clusterTime - the $clusterTime returned by the server from another session in the form of a document containing the `BSON.Timestamp` clusterTime and signature
|
|
1086
|
+
*/
|
|
1087
|
+
advanceClusterTime(clusterTime: ClusterTime): void;
|
|
1034
1088
|
/**
|
|
1035
1089
|
* Used to determine if this session equals another
|
|
1036
1090
|
*
|
|
@@ -1246,10 +1300,10 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
1246
1300
|
* @param options - Optional settings for the command
|
|
1247
1301
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
1248
1302
|
*/
|
|
1249
|
-
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>): Promise<UpdateResult
|
|
1250
|
-
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>, callback: Callback<UpdateResult
|
|
1251
|
-
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>, options: UpdateOptions): Promise<UpdateResult
|
|
1252
|
-
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>, options: UpdateOptions, callback: Callback<UpdateResult
|
|
1303
|
+
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>): Promise<UpdateResult>;
|
|
1304
|
+
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>, callback: Callback<UpdateResult>): void;
|
|
1305
|
+
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>, options: UpdateOptions): Promise<UpdateResult>;
|
|
1306
|
+
updateOne(filter: Filter<TSchema>, update: UpdateFilter<TSchema> | Partial<TSchema>, options: UpdateOptions, callback: Callback<UpdateResult>): void;
|
|
1253
1307
|
/**
|
|
1254
1308
|
* Replace a document in a collection with another document
|
|
1255
1309
|
*
|
|
@@ -1308,7 +1362,7 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
1308
1362
|
*/
|
|
1309
1363
|
rename(newName: string): Promise<Collection>;
|
|
1310
1364
|
rename(newName: string, callback: Callback<Collection>): void;
|
|
1311
|
-
rename(newName: string, options: RenameOptions): Promise<Collection
|
|
1365
|
+
rename(newName: string, options: RenameOptions): Promise<Collection>;
|
|
1312
1366
|
rename(newName: string, options: RenameOptions, callback: Callback<Collection>): void;
|
|
1313
1367
|
/**
|
|
1314
1368
|
* Drop the collection from the database, removing it permanently. New accesses will create a new collection.
|
|
@@ -1327,25 +1381,25 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
1327
1381
|
* @param options - Optional settings for the command
|
|
1328
1382
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
1329
1383
|
*/
|
|
1330
|
-
findOne(): Promise<TSchema |
|
|
1331
|
-
findOne(callback: Callback<TSchema |
|
|
1332
|
-
findOne(filter: Filter<TSchema>): Promise<TSchema |
|
|
1333
|
-
findOne(filter: Filter<TSchema>, callback: Callback<TSchema |
|
|
1334
|
-
findOne(filter: Filter<TSchema>, options: FindOptions
|
|
1335
|
-
findOne(filter: Filter<TSchema>, options: FindOptions
|
|
1336
|
-
findOne<T = TSchema>(): Promise<T |
|
|
1337
|
-
findOne<T = TSchema>(callback: Callback<T |
|
|
1338
|
-
findOne<T = TSchema>(filter: Filter<
|
|
1339
|
-
findOne<T = TSchema>(filter: Filter<
|
|
1340
|
-
findOne<T = TSchema>(filter: Filter<
|
|
1384
|
+
findOne(): Promise<TSchema | null>;
|
|
1385
|
+
findOne(callback: Callback<TSchema | null>): void;
|
|
1386
|
+
findOne(filter: Filter<TSchema>): Promise<TSchema | null>;
|
|
1387
|
+
findOne(filter: Filter<TSchema>, callback: Callback<TSchema | null>): void;
|
|
1388
|
+
findOne(filter: Filter<TSchema>, options: FindOptions): Promise<TSchema | null>;
|
|
1389
|
+
findOne(filter: Filter<TSchema>, options: FindOptions, callback: Callback<TSchema | null>): void;
|
|
1390
|
+
findOne<T = TSchema>(): Promise<T | null>;
|
|
1391
|
+
findOne<T = TSchema>(callback: Callback<T | null>): void;
|
|
1392
|
+
findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
|
|
1393
|
+
findOne<T = TSchema>(filter: Filter<TSchema>, options?: FindOptions): Promise<T | null>;
|
|
1394
|
+
findOne<T = TSchema>(filter: Filter<TSchema>, options?: FindOptions, callback?: Callback<T | null>): void;
|
|
1341
1395
|
/**
|
|
1342
1396
|
* Creates a cursor for a filter that can be used to iterate over results from MongoDB
|
|
1343
1397
|
*
|
|
1344
1398
|
* @param filter - The filter predicate. If unspecified, then all documents in the collection will match the predicate
|
|
1345
1399
|
*/
|
|
1346
1400
|
find(): FindCursor<TSchema>;
|
|
1347
|
-
find(filter: Filter<TSchema>, options?: FindOptions
|
|
1348
|
-
find<T
|
|
1401
|
+
find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema>;
|
|
1402
|
+
find<T>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
|
|
1349
1403
|
/**
|
|
1350
1404
|
* Returns the options of the collection.
|
|
1351
1405
|
*
|
|
@@ -1552,10 +1606,10 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
1552
1606
|
* @param options - Optional settings for the command
|
|
1553
1607
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
1554
1608
|
*/
|
|
1555
|
-
indexes(): Promise<Document>;
|
|
1556
|
-
indexes(callback: Callback<Document>): void;
|
|
1557
|
-
indexes(options: IndexInformationOptions): Promise<Document>;
|
|
1558
|
-
indexes(options: IndexInformationOptions, callback: Callback<Document>): void;
|
|
1609
|
+
indexes(): Promise<Document[]>;
|
|
1610
|
+
indexes(callback: Callback<Document[]>): void;
|
|
1611
|
+
indexes(options: IndexInformationOptions): Promise<Document[]>;
|
|
1612
|
+
indexes(options: IndexInformationOptions, callback: Callback<Document[]>): void;
|
|
1559
1613
|
/**
|
|
1560
1614
|
* Get all the collection statistics.
|
|
1561
1615
|
*
|
|
@@ -1574,8 +1628,8 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
1574
1628
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
1575
1629
|
*/
|
|
1576
1630
|
findOneAndDelete(filter: Filter<TSchema>): Promise<ModifyResult<TSchema>>;
|
|
1577
|
-
findOneAndDelete(filter: Filter<TSchema>, callback: Callback<ModifyResult<TSchema>>): void;
|
|
1578
1631
|
findOneAndDelete(filter: Filter<TSchema>, options: FindOneAndDeleteOptions): Promise<ModifyResult<TSchema>>;
|
|
1632
|
+
findOneAndDelete(filter: Filter<TSchema>, callback: Callback<ModifyResult<TSchema>>): void;
|
|
1579
1633
|
findOneAndDelete(filter: Filter<TSchema>, options: FindOneAndDeleteOptions, callback: Callback<ModifyResult<TSchema>>): void;
|
|
1580
1634
|
/**
|
|
1581
1635
|
* Find a document and replace it in one atomic operation. Requires a write lock for the duration of the operation.
|
|
@@ -1774,11 +1828,14 @@ export declare class CommandFailedEvent {
|
|
|
1774
1828
|
duration: number;
|
|
1775
1829
|
commandName: string;
|
|
1776
1830
|
failure: Error;
|
|
1831
|
+
serviceId?: ObjectId;
|
|
1832
|
+
/*Excluded from this release type: __constructor */
|
|
1833
|
+
readonly hasServiceId: boolean;
|
|
1777
1834
|
}
|
|
1778
1835
|
/* Excluded from this release type: CommandOperation */
|
|
1779
1836
|
/** @public */
|
|
1780
1837
|
export declare interface CommandOperationOptions extends OperationOptions, WriteConcernOptions, ExplainOptions {
|
|
1781
|
-
/**
|
|
1838
|
+
/** @deprecated This option does nothing */
|
|
1782
1839
|
fullResponse?: boolean;
|
|
1783
1840
|
/** Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported) */
|
|
1784
1841
|
readConcern?: ReadConcernLike;
|
|
@@ -1793,23 +1850,7 @@ export declare interface CommandOperationOptions extends OperationOptions, Write
|
|
|
1793
1850
|
authdb?: string;
|
|
1794
1851
|
noResponse?: boolean;
|
|
1795
1852
|
}
|
|
1796
|
-
|
|
1797
|
-
export declare interface CommandOptions extends BSONSerializeOptions {
|
|
1798
|
-
command?: boolean;
|
|
1799
|
-
slaveOk?: boolean;
|
|
1800
|
-
/** Specify read preference if command supports it */
|
|
1801
|
-
readPreference?: ReadPreferenceLike;
|
|
1802
|
-
raw?: boolean;
|
|
1803
|
-
monitoring?: boolean;
|
|
1804
|
-
fullResult?: boolean;
|
|
1805
|
-
socketTimeoutMS?: number;
|
|
1806
|
-
/** Session to use for the operation */
|
|
1807
|
-
session?: ClientSession;
|
|
1808
|
-
documentsReturnedIn?: string;
|
|
1809
|
-
noResponse?: boolean;
|
|
1810
|
-
willRetryWrite?: boolean;
|
|
1811
|
-
writeConcern?: WriteConcernOptions | WriteConcern | W;
|
|
1812
|
-
}
|
|
1853
|
+
/* Excluded from this release type: CommandOptions */
|
|
1813
1854
|
/**
|
|
1814
1855
|
* An event indicating the start of a given
|
|
1815
1856
|
* @public
|
|
@@ -1823,6 +1864,9 @@ export declare class CommandStartedEvent {
|
|
|
1823
1864
|
command: Document;
|
|
1824
1865
|
address: string;
|
|
1825
1866
|
connectionId?: string | number;
|
|
1867
|
+
serviceId?: ObjectId;
|
|
1868
|
+
/*Excluded from this release type: __constructor */
|
|
1869
|
+
readonly hasServiceId: boolean;
|
|
1826
1870
|
}
|
|
1827
1871
|
/**
|
|
1828
1872
|
* An event indicating the success of a given command
|
|
@@ -1836,6 +1880,9 @@ export declare class CommandSucceededEvent {
|
|
|
1836
1880
|
duration: number;
|
|
1837
1881
|
commandName: string;
|
|
1838
1882
|
reply: unknown;
|
|
1883
|
+
serviceId?: ObjectId;
|
|
1884
|
+
/*Excluded from this release type: __constructor */
|
|
1885
|
+
readonly hasServiceId: boolean;
|
|
1839
1886
|
}
|
|
1840
1887
|
/** @public */
|
|
1841
1888
|
export declare type CommonEvents = 'newListener' | 'removeListener';
|
|
@@ -1896,6 +1943,7 @@ export declare class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent
|
|
|
1896
1943
|
connectionId: number | '<monitor>';
|
|
1897
1944
|
/** The reason the connection was closed */
|
|
1898
1945
|
reason: string;
|
|
1946
|
+
serviceId?: ObjectId;
|
|
1899
1947
|
}
|
|
1900
1948
|
/**
|
|
1901
1949
|
* An event published when a connection pool creates a new connection
|
|
@@ -1914,6 +1962,8 @@ export declare type ConnectionEvents = {
|
|
|
1914
1962
|
clusterTimeReceived(clusterTime: Document): void;
|
|
1915
1963
|
close(): void;
|
|
1916
1964
|
message(message: any): void;
|
|
1965
|
+
pinned(pinType: string): void;
|
|
1966
|
+
unpinned(pinType: string): void;
|
|
1917
1967
|
};
|
|
1918
1968
|
/** @public */
|
|
1919
1969
|
export declare interface ConnectionOptions extends SupportedNodeConnectionOptions, StreamDescriptionOptions {
|
|
@@ -1971,6 +2021,7 @@ export declare type ConnectionPoolEvents = {
|
|
|
1971
2021
|
connectionCheckedOut(event: ConnectionCheckedOutEvent): void;
|
|
1972
2022
|
connectionCheckedIn(event: ConnectionCheckedInEvent): void;
|
|
1973
2023
|
} & Pick<ConnectionEvents, Exclude<keyof ConnectionEvents, 'close' | 'message'>>;
|
|
2024
|
+
/* Excluded from this release type: ConnectionPoolMetrics */
|
|
1974
2025
|
/**
|
|
1975
2026
|
* The base export class for all monitoring events published from the connection pool
|
|
1976
2027
|
* @public
|
|
@@ -1992,6 +2043,8 @@ export declare interface ConnectionPoolOptions extends Pick<ConnectionOptions, E
|
|
|
1992
2043
|
maxIdleTimeMS: number;
|
|
1993
2044
|
/** The maximum amount of time operation execution should wait for a connection to become available. The default is 0 which means there is no limit. */
|
|
1994
2045
|
waitQueueTimeoutMS: number;
|
|
2046
|
+
/** If we are in load balancer mode. */
|
|
2047
|
+
loadBalanced: boolean;
|
|
1995
2048
|
}
|
|
1996
2049
|
/**
|
|
1997
2050
|
* An event published when a connection is ready for use
|
|
@@ -2073,9 +2126,12 @@ export declare interface CreateIndexesOptions extends CommandOperationOptions {
|
|
|
2073
2126
|
sparse?: boolean;
|
|
2074
2127
|
/** Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) */
|
|
2075
2128
|
expireAfterSeconds?: number;
|
|
2129
|
+
/** Allows users to configure the storage engine on a per-index basis when creating an index. (MongoDB 3.0 or higher) */
|
|
2076
2130
|
storageEngine?: Document;
|
|
2077
2131
|
/** (MongoDB 4.4. or higher) Specifies how many data-bearing members of a replica set, including the primary, must complete the index builds successfully before the primary marks the indexes as ready. This option accepts the same values for the "w" field in a write concern plus "votingMembers", which indicates all voting data-bearing nodes. */
|
|
2078
2132
|
commitQuorum?: number | string;
|
|
2133
|
+
/** Specifies the index version number, either 0 or 1. */
|
|
2134
|
+
version?: number;
|
|
2079
2135
|
weights?: Document;
|
|
2080
2136
|
default_language?: string;
|
|
2081
2137
|
language_override?: string;
|
|
@@ -2088,6 +2144,8 @@ export declare interface CreateIndexesOptions extends CommandOperationOptions {
|
|
|
2088
2144
|
max?: number;
|
|
2089
2145
|
bucketSize?: number;
|
|
2090
2146
|
wildcardProjection?: Document;
|
|
2147
|
+
/** Specifies that the index should exist on the target collection but should not be used by the query planner when executing operations. (MongoDB 4.4 or higher) */
|
|
2148
|
+
hidden?: boolean;
|
|
2091
2149
|
}
|
|
2092
2150
|
/** @public */
|
|
2093
2151
|
export declare const CURSOR_FLAGS: readonly [
|
|
@@ -2098,9 +2156,11 @@ export declare const CURSOR_FLAGS: readonly [
|
|
|
2098
2156
|
"exhaust",
|
|
2099
2157
|
"partial"
|
|
2100
2158
|
];
|
|
2101
|
-
/** @public
|
|
2159
|
+
/** @public
|
|
2160
|
+
* @deprecated This interface is deprecated */
|
|
2102
2161
|
export declare interface CursorCloseOptions {
|
|
2103
2162
|
/** Bypass calling killCursors when closing the cursor. */
|
|
2163
|
+
/** @deprecated the skipKillCursors option is deprecated */
|
|
2104
2164
|
skipKillCursors?: boolean;
|
|
2105
2165
|
}
|
|
2106
2166
|
/** @public */
|
|
@@ -2189,7 +2249,7 @@ export declare class Db {
|
|
|
2189
2249
|
* @param pipeline - An array of aggregation stages to be executed
|
|
2190
2250
|
* @param options - Optional settings for the command
|
|
2191
2251
|
*/
|
|
2192
|
-
aggregate(pipeline?: Document[], options?: AggregateOptions): AggregationCursor
|
|
2252
|
+
aggregate<T = Document>(pipeline?: Document[], options?: AggregateOptions): AggregationCursor<T>;
|
|
2193
2253
|
/** Return the Admin db instance */
|
|
2194
2254
|
admin(): Admin;
|
|
2195
2255
|
/**
|
|
@@ -2198,7 +2258,7 @@ export declare class Db {
|
|
|
2198
2258
|
* @param name - the collection name we wish to access.
|
|
2199
2259
|
* @returns return the new Collection instance
|
|
2200
2260
|
*/
|
|
2201
|
-
collection<TSchema extends Document = Document>(name: string): Collection<TSchema>;
|
|
2261
|
+
collection<TSchema extends Document = Document>(name: string, options?: CollectionOptions): Collection<TSchema>;
|
|
2202
2262
|
/**
|
|
2203
2263
|
* Get all the db statistics.
|
|
2204
2264
|
*
|
|
@@ -2339,7 +2399,10 @@ export declare class Db {
|
|
|
2339
2399
|
indexInformation(name: string, callback: Callback<Document>): void;
|
|
2340
2400
|
indexInformation(name: string, options: IndexInformationOptions): Promise<Document>;
|
|
2341
2401
|
indexInformation(name: string, options: IndexInformationOptions, callback: Callback<Document>): void;
|
|
2342
|
-
/**
|
|
2402
|
+
/**
|
|
2403
|
+
* Unref all sockets
|
|
2404
|
+
* @deprecated This function is deprecated and will be removed in the next major version.
|
|
2405
|
+
*/
|
|
2343
2406
|
unref(): void;
|
|
2344
2407
|
/**
|
|
2345
2408
|
* Create a new Change Stream, watching for new changes (insertions, updates,
|
|
@@ -2455,15 +2518,21 @@ export declare type DropDatabaseOptions = CommandOperationOptions;
|
|
|
2455
2518
|
export declare type DropIndexesOptions = CommandOperationOptions;
|
|
2456
2519
|
/* Excluded from this release type: Encrypter */
|
|
2457
2520
|
/* Excluded from this release type: EncrypterOptions */
|
|
2521
|
+
/** @public */
|
|
2522
|
+
export declare interface EndSessionOptions {
|
|
2523
|
+
/* Excluded from this release type: error */
|
|
2524
|
+
force?: boolean;
|
|
2525
|
+
forceClear?: boolean;
|
|
2526
|
+
}
|
|
2458
2527
|
/** TypeScript Omit (Exclude to be specific) does not work for objects with an "any" indexed type, and breaks discriminated unions @public */
|
|
2459
2528
|
export declare type EnhancedOmit<TRecordOrUnion, KeyUnion> = string extends keyof TRecordOrUnion ? TRecordOrUnion : TRecordOrUnion extends any ? Pick<TRecordOrUnion, Exclude<keyof TRecordOrUnion, KeyUnion>> : never;
|
|
2460
2529
|
/** @public */
|
|
2461
|
-
export declare interface ErrorDescription {
|
|
2530
|
+
export declare interface ErrorDescription extends Document {
|
|
2462
2531
|
message?: string;
|
|
2463
2532
|
errmsg?: string;
|
|
2464
2533
|
$err?: string;
|
|
2465
2534
|
errorLabels?: string[];
|
|
2466
|
-
|
|
2535
|
+
errInfo?: Document;
|
|
2467
2536
|
}
|
|
2468
2537
|
/** @public */
|
|
2469
2538
|
export declare interface EstimatedDocumentCountOptions extends CommandOperationOptions {
|
|
@@ -2521,11 +2590,11 @@ export declare interface FilterOperators<TValue> extends Document {
|
|
|
2521
2590
|
$eq?: TValue;
|
|
2522
2591
|
$gt?: TValue;
|
|
2523
2592
|
$gte?: TValue;
|
|
2524
|
-
$in?: TValue
|
|
2593
|
+
$in?: ReadonlyArray<TValue>;
|
|
2525
2594
|
$lt?: TValue;
|
|
2526
2595
|
$lte?: TValue;
|
|
2527
2596
|
$ne?: TValue;
|
|
2528
|
-
$nin?: TValue
|
|
2597
|
+
$nin?: ReadonlyArray<TValue>;
|
|
2529
2598
|
$not?: TValue extends string ? FilterOperators<TValue> | RegExp : FilterOperators<TValue>;
|
|
2530
2599
|
/**
|
|
2531
2600
|
* When `true`, `$exists` matches the documents that contain the field,
|
|
@@ -2548,8 +2617,8 @@ export declare interface FilterOperators<TValue> extends Document {
|
|
|
2548
2617
|
$near?: Document;
|
|
2549
2618
|
$nearSphere?: Document;
|
|
2550
2619
|
$maxDistance?: number;
|
|
2551
|
-
$all?:
|
|
2552
|
-
$elemMatch?:
|
|
2620
|
+
$all?: ReadonlyArray<any>;
|
|
2621
|
+
$elemMatch?: Document;
|
|
2553
2622
|
$size?: TValue extends ReadonlyArray<any> ? number : never;
|
|
2554
2623
|
$bitsAllClear?: BitwiseFilter;
|
|
2555
2624
|
$bitsAllSet?: BitwiseFilter;
|
|
@@ -2644,18 +2713,40 @@ export declare class FindCursor<TSchema = Document> extends AbstractCursor<TSche
|
|
|
2644
2713
|
* In order to strictly type this function you must provide an interface
|
|
2645
2714
|
* that represents the effect of your projection on the result documents.
|
|
2646
2715
|
*
|
|
2647
|
-
*
|
|
2716
|
+
* By default chaining a projection to your cursor changes the returned type to the generic
|
|
2717
|
+
* {@link Document} type.
|
|
2718
|
+
* You should specify a parameterized type to have assertions on your final results.
|
|
2719
|
+
*
|
|
2720
|
+
* @example
|
|
2721
|
+
* ```typescript
|
|
2722
|
+
* // Best way
|
|
2723
|
+
* const docs: FindCursor<{ a: number }> = cursor.project<{ a: number }>({ _id: 0, a: true });
|
|
2724
|
+
* // Flexible way
|
|
2725
|
+
* const docs: FindCursor<Document> = cursor.project({ _id: 0, a: true });
|
|
2726
|
+
* ```
|
|
2727
|
+
*
|
|
2728
|
+
* @remarks
|
|
2729
|
+
*
|
|
2730
|
+
* **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
|
|
2648
2731
|
* it **does not** return a new instance of a cursor. This means when calling project,
|
|
2649
|
-
* you should always assign the result to a new variable
|
|
2732
|
+
* you should always assign the result to a new variable in order to get a correctly typed cursor variable.
|
|
2733
|
+
* Take note of the following example:
|
|
2650
2734
|
*
|
|
2651
2735
|
* @example
|
|
2652
2736
|
* ```typescript
|
|
2653
2737
|
* const cursor: FindCursor<{ a: number; b: string }> = coll.find();
|
|
2654
|
-
* const projectCursor = cursor.project<{ a: number }>({ a: true });
|
|
2738
|
+
* const projectCursor = cursor.project<{ a: number }>({ _id: 0, a: true });
|
|
2655
2739
|
* const aPropOnlyArray: {a: number}[] = await projectCursor.toArray();
|
|
2740
|
+
*
|
|
2741
|
+
* // or always use chaining and save the final cursor
|
|
2742
|
+
*
|
|
2743
|
+
* const cursor = coll.find().project<{ a: string }>({
|
|
2744
|
+
* _id: 0,
|
|
2745
|
+
* a: { $convert: { input: '$a', to: 'string' }
|
|
2746
|
+
* }});
|
|
2656
2747
|
* ```
|
|
2657
2748
|
*/
|
|
2658
|
-
project<T =
|
|
2749
|
+
project<T extends Document = Document>(value: Document): FindCursor<T>;
|
|
2659
2750
|
/**
|
|
2660
2751
|
* Sets the sort order of the cursor query.
|
|
2661
2752
|
*
|
|
@@ -2762,14 +2853,17 @@ export declare class FindOperators {
|
|
|
2762
2853
|
/** Specifies arrayFilters for UpdateOne or UpdateMany bulk operations. */
|
|
2763
2854
|
arrayFilters(arrayFilters: Document[]): this;
|
|
2764
2855
|
}
|
|
2765
|
-
/**
|
|
2766
|
-
|
|
2856
|
+
/**
|
|
2857
|
+
* @public
|
|
2858
|
+
* @typeParam TSchema - Unused schema definition, deprecated usage, only specify `FindOptions` with no generic
|
|
2859
|
+
*/
|
|
2860
|
+
export declare interface FindOptions<TSchema extends Document = Document> extends CommandOperationOptions {
|
|
2767
2861
|
/** Sets the limit of documents returned in the query. */
|
|
2768
2862
|
limit?: number;
|
|
2769
2863
|
/** Set to sort the documents coming back from the query. Array of indexes, `[['a', 1]]` etc. */
|
|
2770
2864
|
sort?: Sort;
|
|
2771
2865
|
/** The fields to return in the query. Object of fields to either include or exclude (one of, not both), `{'a':1, 'b': 1}` **or** `{'a': 0, 'b': 0}` */
|
|
2772
|
-
projection?:
|
|
2866
|
+
projection?: Document;
|
|
2773
2867
|
/** Set to skip N documents ahead in your query (useful for pagination). */
|
|
2774
2868
|
skip?: number;
|
|
2775
2869
|
/** Tell the query to use specific indexes in the query. Object of indexes to use, `{'_id':1}` */
|
|
@@ -2899,7 +2993,7 @@ export declare interface GridFSBucketOptions extends WriteConcernOptions {
|
|
|
2899
2993
|
* Do not instantiate this class directly. Use `openDownloadStream()` instead.
|
|
2900
2994
|
* @public
|
|
2901
2995
|
*/
|
|
2902
|
-
export declare class GridFSBucketReadStream extends Readable {
|
|
2996
|
+
export declare class GridFSBucketReadStream extends Readable implements NodeJS.ReadableStream {
|
|
2903
2997
|
/* Excluded from this release type: s */
|
|
2904
2998
|
/**
|
|
2905
2999
|
* An error occurred
|
|
@@ -2976,7 +3070,7 @@ export declare interface GridFSBucketReadStreamOptionsWithRevision extends GridF
|
|
|
2976
3070
|
* Do not instantiate this class directly. Use `openUploadStream()` instead.
|
|
2977
3071
|
* @public
|
|
2978
3072
|
*/
|
|
2979
|
-
export declare class GridFSBucketWriteStream extends Writable {
|
|
3073
|
+
export declare class GridFSBucketWriteStream extends Writable implements NodeJS.WritableStream {
|
|
2980
3074
|
bucket: GridFSBucket;
|
|
2981
3075
|
chunks: Collection<GridFSChunk>;
|
|
2982
3076
|
filename: string;
|
|
@@ -3014,10 +3108,10 @@ export declare class GridFSBucketWriteStream extends Writable {
|
|
|
3014
3108
|
* @param callback - Function to call when the chunk was added to the buffer, or if the entire chunk was persisted to MongoDB if this chunk caused a flush.
|
|
3015
3109
|
* @returns False if this write required flushing a chunk to MongoDB. True otherwise.
|
|
3016
3110
|
*/
|
|
3017
|
-
write(chunk: Buffer): boolean;
|
|
3018
|
-
write(chunk: Buffer, callback: Callback<void>): boolean;
|
|
3019
|
-
write(chunk: Buffer, encoding: BufferEncoding | undefined): boolean;
|
|
3020
|
-
write(chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<void>): boolean;
|
|
3111
|
+
write(chunk: Buffer | string): boolean;
|
|
3112
|
+
write(chunk: Buffer | string, callback: Callback<void>): boolean;
|
|
3113
|
+
write(chunk: Buffer | string, encoding: BufferEncoding | undefined): boolean;
|
|
3114
|
+
write(chunk: Buffer | string, encoding: BufferEncoding | undefined, callback: Callback<void>): boolean;
|
|
3021
3115
|
/**
|
|
3022
3116
|
* Places this write stream into an aborted state (all future writes fail)
|
|
3023
3117
|
* and deletes all chunks that have already been written.
|
|
@@ -3094,7 +3188,7 @@ export declare class HostAddress {
|
|
|
3094
3188
|
static fromString(s: string): HostAddress;
|
|
3095
3189
|
}
|
|
3096
3190
|
/** @public */
|
|
3097
|
-
export declare interface IndexDescription {
|
|
3191
|
+
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'> {
|
|
3098
3192
|
collation?: CollationOptions;
|
|
3099
3193
|
name?: string;
|
|
3100
3194
|
key: Document;
|
|
@@ -3168,6 +3262,7 @@ export declare type IsAny<Type, ResultIfAny, ResultIfNotAny> = true extends fals
|
|
|
3168
3262
|
/* Excluded from this release type: kCancellationToken_2 */
|
|
3169
3263
|
/* Excluded from this release type: kCancelled */
|
|
3170
3264
|
/* Excluded from this release type: kCancelled_2 */
|
|
3265
|
+
/* Excluded from this release type: kCheckedOut */
|
|
3171
3266
|
/* Excluded from this release type: kClosed */
|
|
3172
3267
|
/* Excluded from this release type: kClosed_2 */
|
|
3173
3268
|
/* Excluded from this release type: kClusterTime */
|
|
@@ -3187,6 +3282,7 @@ export declare type KeysOfOtherType<TSchema, Type> = {
|
|
|
3187
3282
|
[key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key;
|
|
3188
3283
|
}[keyof TSchema];
|
|
3189
3284
|
/* Excluded from this release type: kFilter */
|
|
3285
|
+
/* Excluded from this release type: kFullResult */
|
|
3190
3286
|
/* Excluded from this release type: kGeneration */
|
|
3191
3287
|
/* Excluded from this release type: kGeneration_2 */
|
|
3192
3288
|
/* Excluded from this release type: kId */
|
|
@@ -3199,6 +3295,7 @@ export declare type KeysOfOtherType<TSchema, Type> = {
|
|
|
3199
3295
|
/* Excluded from this release type: kLength */
|
|
3200
3296
|
/* Excluded from this release type: kLogger */
|
|
3201
3297
|
/* Excluded from this release type: kMessageStream */
|
|
3298
|
+
/* Excluded from this release type: kMetrics */
|
|
3202
3299
|
/* Excluded from this release type: kMinPoolSizeTimer */
|
|
3203
3300
|
/* Excluded from this release type: kMode */
|
|
3204
3301
|
/* Excluded from this release type: kMonitor */
|
|
@@ -3208,16 +3305,19 @@ export declare type KeysOfOtherType<TSchema, Type> = {
|
|
|
3208
3305
|
/* Excluded from this release type: kOptions */
|
|
3209
3306
|
/* Excluded from this release type: kOptions_2 */
|
|
3210
3307
|
/* Excluded from this release type: kOptions_3 */
|
|
3211
|
-
/* Excluded from this release type: kParent */
|
|
3212
3308
|
/* Excluded from this release type: kPermits */
|
|
3309
|
+
/* Excluded from this release type: kPinnedConnection */
|
|
3213
3310
|
/* Excluded from this release type: kPipeline */
|
|
3311
|
+
/* Excluded from this release type: kProcessingWaitQueue */
|
|
3214
3312
|
/* Excluded from this release type: kQueue */
|
|
3215
3313
|
/* Excluded from this release type: kResumeQueue */
|
|
3216
3314
|
/* Excluded from this release type: kRoundTripTime */
|
|
3217
3315
|
/* Excluded from this release type: kRTTPinger */
|
|
3218
3316
|
/* Excluded from this release type: kServer */
|
|
3219
3317
|
/* Excluded from this release type: kServer_2 */
|
|
3318
|
+
/* Excluded from this release type: kServerError */
|
|
3220
3319
|
/* Excluded from this release type: kServerSession */
|
|
3320
|
+
/* Excluded from this release type: kServiceGenerations */
|
|
3221
3321
|
/* Excluded from this release type: kSession */
|
|
3222
3322
|
/* Excluded from this release type: kSession_2 */
|
|
3223
3323
|
/* Excluded from this release type: kSnapshotEnabled */
|
|
@@ -3255,7 +3355,7 @@ export declare const LEGAL_TLS_SOCKET_OPTIONS: readonly [
|
|
|
3255
3355
|
"session"
|
|
3256
3356
|
];
|
|
3257
3357
|
/** @public */
|
|
3258
|
-
export declare class ListCollectionsCursor<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = CollectionInfo> extends AbstractCursor<T> {
|
|
3358
|
+
export declare class ListCollectionsCursor<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo> extends AbstractCursor<T> {
|
|
3259
3359
|
parent: Db;
|
|
3260
3360
|
filter: Document;
|
|
3261
3361
|
options?: ListCollectionsOptions;
|
|
@@ -3427,7 +3527,7 @@ export { MaxKey };
|
|
|
3427
3527
|
export { MinKey };
|
|
3428
3528
|
/** @public */
|
|
3429
3529
|
export declare interface ModifyResult<TSchema = Document> {
|
|
3430
|
-
value
|
|
3530
|
+
value: TSchema | null;
|
|
3431
3531
|
lastErrorObject?: Document;
|
|
3432
3532
|
ok: 0 | 1;
|
|
3433
3533
|
}
|
|
@@ -3445,6 +3545,30 @@ export declare const MONGO_CLIENT_EVENTS: readonly [
|
|
|
3445
3545
|
"connectionPoolCleared",
|
|
3446
3546
|
...("error" | "close" | "commandStarted" | "commandSucceeded" | "commandFailed" | "serverHeartbeatStarted" | "serverHeartbeatSucceeded" | "serverHeartbeatFailed" | "timeout" | "serverOpening" | "serverClosed" | "serverDescriptionChanged" | "topologyOpening" | "topologyClosed" | "topologyDescriptionChanged")[]
|
|
3447
3547
|
];
|
|
3548
|
+
/**
|
|
3549
|
+
* An error generated when the driver API is used incorrectly
|
|
3550
|
+
*
|
|
3551
|
+
* @privateRemarks
|
|
3552
|
+
* Should **never** be directly instantiated
|
|
3553
|
+
*
|
|
3554
|
+
* @public
|
|
3555
|
+
* @category Error
|
|
3556
|
+
*/
|
|
3557
|
+
export declare class MongoAPIError extends MongoDriverError {
|
|
3558
|
+
constructor(message: string);
|
|
3559
|
+
readonly name: string;
|
|
3560
|
+
}
|
|
3561
|
+
/**
|
|
3562
|
+
* An error generated when a batch command is reexecuted after one of the commands in the batch
|
|
3563
|
+
* has failed
|
|
3564
|
+
*
|
|
3565
|
+
* @public
|
|
3566
|
+
* @category Error
|
|
3567
|
+
*/
|
|
3568
|
+
export declare class MongoBatchReExecutionError extends MongoAPIError {
|
|
3569
|
+
constructor(message?: string);
|
|
3570
|
+
readonly name: string;
|
|
3571
|
+
}
|
|
3448
3572
|
/**
|
|
3449
3573
|
* An error indicating an unsuccessful Bulk Write
|
|
3450
3574
|
* @public
|
|
@@ -3452,8 +3576,14 @@ export declare const MONGO_CLIENT_EVENTS: readonly [
|
|
|
3452
3576
|
*/
|
|
3453
3577
|
export declare class MongoBulkWriteError extends MongoServerError {
|
|
3454
3578
|
result: BulkWriteResult;
|
|
3579
|
+
writeErrors: OneOrMore<WriteError>;
|
|
3580
|
+
err?: WriteConcernError;
|
|
3455
3581
|
/** Creates a new MongoBulkWriteError */
|
|
3456
|
-
constructor(error:
|
|
3582
|
+
constructor(error: {
|
|
3583
|
+
message: string;
|
|
3584
|
+
code: number;
|
|
3585
|
+
writeErrors?: WriteError[];
|
|
3586
|
+
} | WriteConcernError | AnyError, result: BulkWriteResult);
|
|
3457
3587
|
readonly name: string;
|
|
3458
3588
|
/*Number of documents inserted. */
|
|
3459
3589
|
readonly insertedCount: number;
|
|
@@ -3474,6 +3604,16 @@ export declare class MongoBulkWriteError extends MongoServerError {
|
|
|
3474
3604
|
[key: number]: any;
|
|
3475
3605
|
};
|
|
3476
3606
|
}
|
|
3607
|
+
/**
|
|
3608
|
+
* An error generated when a ChangeStream operation fails to execute.
|
|
3609
|
+
*
|
|
3610
|
+
* @public
|
|
3611
|
+
* @category Error
|
|
3612
|
+
*/
|
|
3613
|
+
export declare class MongoChangeStreamError extends MongoRuntimeError {
|
|
3614
|
+
constructor(message: string);
|
|
3615
|
+
readonly name: string;
|
|
3616
|
+
}
|
|
3477
3617
|
/**
|
|
3478
3618
|
* The **MongoClient** class is a class that allows for making Connections to MongoDB.
|
|
3479
3619
|
* @public
|
|
@@ -3609,7 +3749,7 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
3609
3749
|
ssl?: boolean;
|
|
3610
3750
|
/** Specifies the location of a local TLS Certificate */
|
|
3611
3751
|
tlsCertificateFile?: string;
|
|
3612
|
-
/** Specifies the location of a local .pem file that contains either the client
|
|
3752
|
+
/** Specifies the location of a local .pem file that contains either the client's TLS/SSL certificate and key or only the client's TLS/SSL key when tlsCertificateFile is used to provide the certificate. */
|
|
3613
3753
|
tlsCertificateKeyFile?: string;
|
|
3614
3754
|
/** Specifies the password to de-crypt the tlsCertificateKeyFile. */
|
|
3615
3755
|
tlsCertificateKeyFilePassword?: string;
|
|
@@ -3625,8 +3765,8 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
3625
3765
|
connectTimeoutMS?: number;
|
|
3626
3766
|
/** The time in milliseconds to attempt a send or receive on a socket before the attempt times out. */
|
|
3627
3767
|
socketTimeoutMS?: number;
|
|
3628
|
-
/**
|
|
3629
|
-
compressors?: CompressorName[];
|
|
3768
|
+
/** An array or comma-delimited string of compressors to enable network compression for communication between this client and a mongod/mongos instance. */
|
|
3769
|
+
compressors?: CompressorName[] | string;
|
|
3630
3770
|
/** An integer that specifies the compression level if using zlib for network compression. */
|
|
3631
3771
|
zlibCompressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
|
|
3632
3772
|
/** The maximum number of connections in the connection pool. */
|
|
@@ -3654,12 +3794,7 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
3654
3794
|
/** Specify the authentication mechanism that MongoDB will use to authenticate the connection. */
|
|
3655
3795
|
authMechanism?: AuthMechanism;
|
|
3656
3796
|
/** Specify properties for the specified authMechanism as a comma-separated list of colon-separated key-value pairs. */
|
|
3657
|
-
authMechanismProperties?:
|
|
3658
|
-
SERVICE_NAME?: string;
|
|
3659
|
-
CANONICALIZE_HOST_NAME?: boolean;
|
|
3660
|
-
SERVICE_REALM?: string;
|
|
3661
|
-
[key: string]: any;
|
|
3662
|
-
};
|
|
3797
|
+
authMechanismProperties?: AuthMechanismProperties;
|
|
3663
3798
|
/** The size (in milliseconds) of the latency window for selecting among multiple suitable MongoDB instances. */
|
|
3664
3799
|
localThresholdMS?: number;
|
|
3665
3800
|
/** Specifies how long (in milliseconds) to block for server selection before throwing an exception. */
|
|
@@ -3676,6 +3811,8 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
3676
3811
|
retryWrites?: boolean;
|
|
3677
3812
|
/** Allow a driver to force a Single topology type with a connection string containing one host */
|
|
3678
3813
|
directConnection?: boolean;
|
|
3814
|
+
/** Instruct the driver it is connecting to a load balancer fronting a mongos like service */
|
|
3815
|
+
loadBalanced?: boolean;
|
|
3679
3816
|
/** The write concern w value */
|
|
3680
3817
|
w?: W;
|
|
3681
3818
|
/** The write concern timeout */
|
|
@@ -3736,6 +3873,18 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
3736
3873
|
driverInfo?: DriverInfo;
|
|
3737
3874
|
}
|
|
3738
3875
|
/* Excluded from this release type: MongoClientPrivate */
|
|
3876
|
+
/**
|
|
3877
|
+
* An error generated when a feature that is not enabled or allowed for the current server
|
|
3878
|
+
* configuration is used
|
|
3879
|
+
*
|
|
3880
|
+
*
|
|
3881
|
+
* @public
|
|
3882
|
+
* @category Error
|
|
3883
|
+
*/
|
|
3884
|
+
export declare class MongoCompatibilityError extends MongoAPIError {
|
|
3885
|
+
constructor(message: string);
|
|
3886
|
+
readonly name: string;
|
|
3887
|
+
}
|
|
3739
3888
|
/**
|
|
3740
3889
|
* A representation of the credentials used by MongoDB
|
|
3741
3890
|
* @public
|
|
@@ -3750,7 +3899,7 @@ export declare class MongoCredentials {
|
|
|
3750
3899
|
/** The method used to authenticate */
|
|
3751
3900
|
readonly mechanism: AuthMechanism;
|
|
3752
3901
|
/** Special properties used by some types of auth mechanisms */
|
|
3753
|
-
readonly mechanismProperties:
|
|
3902
|
+
readonly mechanismProperties: AuthMechanismProperties;
|
|
3754
3903
|
constructor(options: MongoCredentialsOptions);
|
|
3755
3904
|
/** Determines if two MongoCredentials objects are equivalent */
|
|
3756
3905
|
equals(other: MongoCredentials): boolean;
|
|
@@ -3771,7 +3920,28 @@ export declare interface MongoCredentialsOptions {
|
|
|
3771
3920
|
source: string;
|
|
3772
3921
|
db?: string;
|
|
3773
3922
|
mechanism?: AuthMechanism;
|
|
3774
|
-
mechanismProperties:
|
|
3923
|
+
mechanismProperties: AuthMechanismProperties;
|
|
3924
|
+
}
|
|
3925
|
+
/**
|
|
3926
|
+
* An error thrown when an attempt is made to read from a cursor that has been exhausted
|
|
3927
|
+
*
|
|
3928
|
+
* @public
|
|
3929
|
+
* @category Error
|
|
3930
|
+
*/
|
|
3931
|
+
export declare class MongoCursorExhaustedError extends MongoAPIError {
|
|
3932
|
+
constructor(message?: string);
|
|
3933
|
+
readonly name: string;
|
|
3934
|
+
}
|
|
3935
|
+
/**
|
|
3936
|
+
* An error thrown when the user attempts to add options to a cursor that has already been
|
|
3937
|
+
* initialized
|
|
3938
|
+
*
|
|
3939
|
+
* @public
|
|
3940
|
+
* @category Error
|
|
3941
|
+
*/
|
|
3942
|
+
export declare class MongoCursorInUseError extends MongoAPIError {
|
|
3943
|
+
constructor(message?: string);
|
|
3944
|
+
readonly name: string;
|
|
3775
3945
|
}
|
|
3776
3946
|
/** @public */
|
|
3777
3947
|
export declare class MongoDBNamespace {
|
|
@@ -3788,6 +3958,17 @@ export declare class MongoDBNamespace {
|
|
|
3788
3958
|
withCollection(collection: string): MongoDBNamespace;
|
|
3789
3959
|
static fromString(namespace?: string): MongoDBNamespace;
|
|
3790
3960
|
}
|
|
3961
|
+
/**
|
|
3962
|
+
* An error generated when the driver fails to decompress
|
|
3963
|
+
* data received from the server.
|
|
3964
|
+
*
|
|
3965
|
+
* @public
|
|
3966
|
+
* @category Error
|
|
3967
|
+
*/
|
|
3968
|
+
export declare class MongoDecompressionError extends MongoRuntimeError {
|
|
3969
|
+
constructor(message: string);
|
|
3970
|
+
readonly name: string;
|
|
3971
|
+
}
|
|
3791
3972
|
/**
|
|
3792
3973
|
* An error generated by the driver
|
|
3793
3974
|
*
|
|
@@ -3795,7 +3976,6 @@ export declare class MongoDBNamespace {
|
|
|
3795
3976
|
* @category Error
|
|
3796
3977
|
*/
|
|
3797
3978
|
export declare class MongoDriverError extends MongoError {
|
|
3798
|
-
code?: string;
|
|
3799
3979
|
constructor(message: string);
|
|
3800
3980
|
readonly name: string;
|
|
3801
3981
|
}
|
|
@@ -3808,6 +3988,11 @@ export declare class MongoDriverError extends MongoError {
|
|
|
3808
3988
|
*/
|
|
3809
3989
|
export declare class MongoError extends Error {
|
|
3810
3990
|
/* Excluded from this release type: [kErrorLabels] */
|
|
3991
|
+
/**
|
|
3992
|
+
* This is a number in MongoServerError and a string in MongoDriverError
|
|
3993
|
+
* @privateRemarks
|
|
3994
|
+
* Define the type override on the subclasses when we can use the override keyword
|
|
3995
|
+
*/
|
|
3811
3996
|
code?: number | string;
|
|
3812
3997
|
topologyVersion?: TopologyVersion;
|
|
3813
3998
|
constructor(message: string | Error);
|
|
@@ -3824,6 +4009,82 @@ export declare class MongoError extends Error {
|
|
|
3824
4009
|
addErrorLabel(label: string): void;
|
|
3825
4010
|
readonly errorLabels: string[];
|
|
3826
4011
|
}
|
|
4012
|
+
/**
|
|
4013
|
+
* An error generated when the user attempts to operate
|
|
4014
|
+
* on a session that has expired or has been closed.
|
|
4015
|
+
*
|
|
4016
|
+
* @public
|
|
4017
|
+
* @category Error
|
|
4018
|
+
*/
|
|
4019
|
+
export declare class MongoExpiredSessionError extends MongoAPIError {
|
|
4020
|
+
constructor(message?: string);
|
|
4021
|
+
readonly name: string;
|
|
4022
|
+
}
|
|
4023
|
+
/**
|
|
4024
|
+
* An error generated when a malformed or invalid chunk is
|
|
4025
|
+
* encountered when reading from a GridFSStream.
|
|
4026
|
+
*
|
|
4027
|
+
* @public
|
|
4028
|
+
* @category Error
|
|
4029
|
+
*/
|
|
4030
|
+
export declare class MongoGridFSChunkError extends MongoRuntimeError {
|
|
4031
|
+
constructor(message: string);
|
|
4032
|
+
readonly name: string;
|
|
4033
|
+
}
|
|
4034
|
+
/** An error generated when a GridFSStream operation fails to execute.
|
|
4035
|
+
*
|
|
4036
|
+
* @public
|
|
4037
|
+
* @category Error
|
|
4038
|
+
*/
|
|
4039
|
+
export declare class MongoGridFSStreamError extends MongoRuntimeError {
|
|
4040
|
+
constructor(message: string);
|
|
4041
|
+
readonly name: string;
|
|
4042
|
+
}
|
|
4043
|
+
/**
|
|
4044
|
+
* An error generated when the user supplies malformed or unexpected arguments
|
|
4045
|
+
* or when a required argument or field is not provided.
|
|
4046
|
+
*
|
|
4047
|
+
*
|
|
4048
|
+
* @public
|
|
4049
|
+
* @category Error
|
|
4050
|
+
*/
|
|
4051
|
+
export declare class MongoInvalidArgumentError extends MongoAPIError {
|
|
4052
|
+
constructor(message: string);
|
|
4053
|
+
readonly name: string;
|
|
4054
|
+
}
|
|
4055
|
+
/**
|
|
4056
|
+
* A error generated when the user attempts to authenticate
|
|
4057
|
+
* via Kerberos, but fails to connect to the Kerberos client.
|
|
4058
|
+
*
|
|
4059
|
+
* @public
|
|
4060
|
+
* @category Error
|
|
4061
|
+
*/
|
|
4062
|
+
export declare class MongoKerberosError extends MongoRuntimeError {
|
|
4063
|
+
constructor(message: string);
|
|
4064
|
+
readonly name: string;
|
|
4065
|
+
}
|
|
4066
|
+
/**
|
|
4067
|
+
* An error generated when the user fails to provide authentication credentials before attempting
|
|
4068
|
+
* to connect to a mongo server instance.
|
|
4069
|
+
*
|
|
4070
|
+
*
|
|
4071
|
+
* @public
|
|
4072
|
+
* @category Error
|
|
4073
|
+
*/
|
|
4074
|
+
export declare class MongoMissingCredentialsError extends MongoAPIError {
|
|
4075
|
+
constructor(message: string);
|
|
4076
|
+
readonly name: string;
|
|
4077
|
+
}
|
|
4078
|
+
/**
|
|
4079
|
+
* An error generated when a required module or dependency is not present in the local environment
|
|
4080
|
+
*
|
|
4081
|
+
* @public
|
|
4082
|
+
* @category Error
|
|
4083
|
+
*/
|
|
4084
|
+
export declare class MongoMissingDependencyError extends MongoAPIError {
|
|
4085
|
+
constructor(message: string);
|
|
4086
|
+
readonly name: string;
|
|
4087
|
+
}
|
|
3827
4088
|
/**
|
|
3828
4089
|
* An error indicating an issue with the network, including TCP errors and timeouts.
|
|
3829
4090
|
* @public
|
|
@@ -3831,11 +4092,14 @@ export declare class MongoError extends Error {
|
|
|
3831
4092
|
*/
|
|
3832
4093
|
export declare class MongoNetworkError extends MongoError {
|
|
3833
4094
|
/* Excluded from this release type: [kBeforeHandshake] */
|
|
3834
|
-
constructor(message: string | Error, options?:
|
|
3835
|
-
beforeHandshake?: boolean;
|
|
3836
|
-
});
|
|
4095
|
+
constructor(message: string | Error, options?: MongoNetworkErrorOptions);
|
|
3837
4096
|
readonly name: string;
|
|
3838
4097
|
}
|
|
4098
|
+
/** @public */
|
|
4099
|
+
export declare interface MongoNetworkErrorOptions {
|
|
4100
|
+
/** Indicates the timeout happened before a connection handshake completed */
|
|
4101
|
+
beforeHandshake: boolean;
|
|
4102
|
+
}
|
|
3839
4103
|
/**
|
|
3840
4104
|
* An error indicating a network timeout occurred
|
|
3841
4105
|
* @public
|
|
@@ -3845,25 +4109,33 @@ export declare class MongoNetworkError extends MongoError {
|
|
|
3845
4109
|
* CSFLE has a dependency on this error with an instanceof check
|
|
3846
4110
|
*/
|
|
3847
4111
|
export declare class MongoNetworkTimeoutError extends MongoNetworkError {
|
|
3848
|
-
constructor(message: string, options?:
|
|
4112
|
+
constructor(message: string, options?: MongoNetworkErrorOptions);
|
|
3849
4113
|
readonly name: string;
|
|
3850
4114
|
}
|
|
3851
|
-
/**
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
4115
|
+
/**
|
|
4116
|
+
* An error thrown when the user attempts to operate on a database or collection through a MongoClient
|
|
4117
|
+
* that has not yet successfully called the "connect" method
|
|
4118
|
+
*
|
|
4119
|
+
* @public
|
|
4120
|
+
* @category Error
|
|
4121
|
+
*/
|
|
4122
|
+
export declare class MongoNotConnectedError extends MongoAPIError {
|
|
4123
|
+
constructor(message: string);
|
|
4124
|
+
readonly name: string;
|
|
3855
4125
|
}
|
|
3856
4126
|
/**
|
|
3857
4127
|
* Mongo Client Options
|
|
3858
4128
|
* @public
|
|
3859
4129
|
*/
|
|
3860
|
-
export declare interface MongoOptions extends Required<Pick<MongoClientOptions, 'autoEncryption' | '
|
|
4130
|
+
export declare interface MongoOptions extends Required<Pick<MongoClientOptions, 'autoEncryption' | 'connectTimeoutMS' | 'directConnection' | 'driverInfo' | 'forceServerObjectId' | 'minHeartbeatFrequencyMS' | 'heartbeatFrequencyMS' | 'keepAlive' | 'keepAliveInitialDelay' | 'localThresholdMS' | 'logger' | 'maxIdleTimeMS' | 'maxPoolSize' | 'minPoolSize' | 'monitorCommands' | 'noDelay' | 'pkFactory' | 'promiseLibrary' | 'raw' | 'replicaSet' | 'retryReads' | 'retryWrites' | 'serverSelectionTimeoutMS' | 'socketTimeoutMS' | 'tlsAllowInvalidCertificates' | 'tlsAllowInvalidHostnames' | 'tlsInsecure' | 'waitQueueTimeoutMS' | 'zlibCompressionLevel'>>, SupportedNodeConnectionOptions {
|
|
3861
4131
|
hosts: HostAddress[];
|
|
3862
4132
|
srvHost?: string;
|
|
3863
4133
|
credentials?: MongoCredentials;
|
|
3864
4134
|
readPreference: ReadPreference;
|
|
3865
4135
|
readConcern: ReadConcern;
|
|
4136
|
+
loadBalanced: boolean;
|
|
3866
4137
|
serverApi: ServerApi;
|
|
4138
|
+
compressors: CompressorName[];
|
|
3867
4139
|
writeConcern: WriteConcern;
|
|
3868
4140
|
dbName: string;
|
|
3869
4141
|
metadata: ClientMetadata;
|
|
@@ -3904,6 +4176,31 @@ export declare class MongoParseError extends MongoDriverError {
|
|
|
3904
4176
|
constructor(message: string);
|
|
3905
4177
|
readonly name: string;
|
|
3906
4178
|
}
|
|
4179
|
+
/**
|
|
4180
|
+
* An error generated when the driver encounters unexpected input
|
|
4181
|
+
* or reaches an unexpected/invalid internal state
|
|
4182
|
+
*
|
|
4183
|
+
* @privateRemarks
|
|
4184
|
+
* Should **never** be directly instantiated.
|
|
4185
|
+
*
|
|
4186
|
+
* @public
|
|
4187
|
+
* @category Error
|
|
4188
|
+
*/
|
|
4189
|
+
export declare class MongoRuntimeError extends MongoDriverError {
|
|
4190
|
+
constructor(message: string);
|
|
4191
|
+
readonly name: string;
|
|
4192
|
+
}
|
|
4193
|
+
/**
|
|
4194
|
+
* An error generated when an attempt is made to operate
|
|
4195
|
+
* on a closed/closing server.
|
|
4196
|
+
*
|
|
4197
|
+
* @public
|
|
4198
|
+
* @category Error
|
|
4199
|
+
*/
|
|
4200
|
+
export declare class MongoServerClosedError extends MongoAPIError {
|
|
4201
|
+
constructor(message?: string);
|
|
4202
|
+
readonly name: string;
|
|
4203
|
+
}
|
|
3907
4204
|
/**
|
|
3908
4205
|
* An error coming from the mongo server
|
|
3909
4206
|
*
|
|
@@ -3911,10 +4208,12 @@ export declare class MongoParseError extends MongoDriverError {
|
|
|
3911
4208
|
* @category Error
|
|
3912
4209
|
*/
|
|
3913
4210
|
export declare class MongoServerError extends MongoError {
|
|
3914
|
-
code?: number;
|
|
3915
4211
|
codeName?: string;
|
|
3916
4212
|
writeConcernError?: Document;
|
|
3917
|
-
|
|
4213
|
+
errInfo?: Document;
|
|
4214
|
+
ok?: number;
|
|
4215
|
+
[key: string]: any;
|
|
4216
|
+
constructor(message: ErrorDescription);
|
|
3918
4217
|
readonly name: string;
|
|
3919
4218
|
}
|
|
3920
4219
|
/**
|
|
@@ -3937,6 +4236,28 @@ export declare class MongoSystemError extends MongoError {
|
|
|
3937
4236
|
constructor(message: string, reason: TopologyDescription);
|
|
3938
4237
|
readonly name: string;
|
|
3939
4238
|
}
|
|
4239
|
+
/**
|
|
4240
|
+
* An error generated when an attempt is made to operate on a
|
|
4241
|
+
* dropped, or otherwise unavailable, database.
|
|
4242
|
+
*
|
|
4243
|
+
* @public
|
|
4244
|
+
* @category Error
|
|
4245
|
+
*/
|
|
4246
|
+
export declare class MongoTopologyClosedError extends MongoAPIError {
|
|
4247
|
+
constructor(message?: string);
|
|
4248
|
+
readonly name: string;
|
|
4249
|
+
}
|
|
4250
|
+
/**
|
|
4251
|
+
* An error generated when the user makes a mistake in the usage of transactions.
|
|
4252
|
+
* (e.g. attempting to commit a transaction with a readPreference other than primary)
|
|
4253
|
+
*
|
|
4254
|
+
* @public
|
|
4255
|
+
* @category Error
|
|
4256
|
+
*/
|
|
4257
|
+
export declare class MongoTransactionError extends MongoAPIError {
|
|
4258
|
+
constructor(message: string);
|
|
4259
|
+
readonly name: string;
|
|
4260
|
+
}
|
|
3940
4261
|
/**
|
|
3941
4262
|
* An error thrown when the server reports a writeConcernError
|
|
3942
4263
|
* @public
|
|
@@ -3945,7 +4266,8 @@ export declare class MongoSystemError extends MongoError {
|
|
|
3945
4266
|
export declare class MongoWriteConcernError extends MongoServerError {
|
|
3946
4267
|
/** The result document (provided if ok: 1) */
|
|
3947
4268
|
result?: Document;
|
|
3948
|
-
|
|
4269
|
+
errInfo?: Document;
|
|
4270
|
+
constructor(message: ErrorDescription, result?: Document);
|
|
3949
4271
|
readonly name: string;
|
|
3950
4272
|
}
|
|
3951
4273
|
/* Excluded from this release type: Monitor */
|
|
@@ -3972,9 +4294,14 @@ export declare type NotAcceptedFields<TSchema, FieldType> = {
|
|
|
3972
4294
|
};
|
|
3973
4295
|
/** @public */
|
|
3974
4296
|
export declare type NumericType = IntegerType | Decimal128 | Double;
|
|
4297
|
+
/**
|
|
4298
|
+
* @public
|
|
4299
|
+
* @deprecated Please use `ObjectId`
|
|
4300
|
+
*/
|
|
4301
|
+
export declare const ObjectID: typeof ObjectId;
|
|
3975
4302
|
export { ObjectId };
|
|
3976
4303
|
/** @public */
|
|
3977
|
-
export declare type OneOrMore<T> = T | T
|
|
4304
|
+
export declare type OneOrMore<T> = T | ReadonlyArray<T>;
|
|
3978
4305
|
/** @public */
|
|
3979
4306
|
export declare type OnlyFieldsOfType<TSchema, FieldType = any, AssignableType = FieldType> = IsAny<TSchema[keyof TSchema], Record<string, FieldType>, AcceptedFields<TSchema, FieldType, AssignableType> & NotAcceptedFields<TSchema, FieldType> & Record<string, AssignableType>>;
|
|
3980
4307
|
/* Excluded from this release type: OperationDescription */
|
|
@@ -4033,21 +4360,17 @@ export declare const ProfilingLevel: Readonly<{
|
|
|
4033
4360
|
export declare type ProfilingLevel = typeof ProfilingLevel[keyof typeof ProfilingLevel];
|
|
4034
4361
|
/** @public */
|
|
4035
4362
|
export declare type ProfilingLevelOptions = CommandOperationOptions;
|
|
4036
|
-
/**
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
export declare
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
$meta?: string;
|
|
4048
|
-
/** @deprecated Since MongoDB 3.2, Use FindCursor#max */
|
|
4049
|
-
$max?: any;
|
|
4050
|
-
}
|
|
4363
|
+
/**
|
|
4364
|
+
* @public
|
|
4365
|
+
* Projection is flexible to permit the wide array of aggregation operators
|
|
4366
|
+
* @deprecated since v4.1.0: Since projections support all aggregation operations we have no plans to narrow this type further
|
|
4367
|
+
*/
|
|
4368
|
+
export declare type Projection<TSchema extends Document = Document> = Document;
|
|
4369
|
+
/**
|
|
4370
|
+
* @public
|
|
4371
|
+
* @deprecated since v4.1.0: Since projections support all aggregation operations we have no plans to narrow this type further
|
|
4372
|
+
*/
|
|
4373
|
+
export declare type ProjectionOperators = Document;
|
|
4051
4374
|
/**
|
|
4052
4375
|
* Global promise store allowing user-provided promises
|
|
4053
4376
|
* @public
|
|
@@ -4065,7 +4388,7 @@ export { Promise_2 as Promise };
|
|
|
4065
4388
|
export declare type PullAllOperator<TSchema> = ({
|
|
4066
4389
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: TSchema[key];
|
|
4067
4390
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
|
4068
|
-
readonly [key: string]: any
|
|
4391
|
+
readonly [key: string]: ReadonlyArray<any>;
|
|
4069
4392
|
};
|
|
4070
4393
|
/** @public */
|
|
4071
4394
|
export declare type PullOperator<TSchema> = ({
|
|
@@ -4524,6 +4847,7 @@ export declare const ServerType: Readonly<{
|
|
|
4524
4847
|
readonly RSOther: "RSOther";
|
|
4525
4848
|
readonly RSGhost: "RSGhost";
|
|
4526
4849
|
readonly Unknown: "Unknown";
|
|
4850
|
+
readonly LoadBalancer: "LoadBalancer";
|
|
4527
4851
|
}>;
|
|
4528
4852
|
/** @public */
|
|
4529
4853
|
export declare type ServerType = typeof ServerType[keyof typeof ServerType];
|
|
@@ -4571,6 +4895,7 @@ export declare class StreamDescription {
|
|
|
4571
4895
|
compressors: CompressorName[];
|
|
4572
4896
|
compressor?: CompressorName;
|
|
4573
4897
|
logicalSessionTimeoutMinutes?: number;
|
|
4898
|
+
loadBalanced: boolean;
|
|
4574
4899
|
__nodejs_mock_server__?: boolean;
|
|
4575
4900
|
zlibCompressionLevel?: number;
|
|
4576
4901
|
constructor(address: string, options?: StreamDescriptionOptions);
|
|
@@ -4579,6 +4904,8 @@ export declare class StreamDescription {
|
|
|
4579
4904
|
/** @public */
|
|
4580
4905
|
export declare interface StreamDescriptionOptions {
|
|
4581
4906
|
compressors?: CompressorName[];
|
|
4907
|
+
logicalSessionTimeoutMinutes?: number;
|
|
4908
|
+
loadBalanced: boolean;
|
|
4582
4909
|
}
|
|
4583
4910
|
/** @public */
|
|
4584
4911
|
export declare type SupportedNodeConnectionOptions = SupportedTLSConnectionOptions & SupportedTLSSocketOptions & SupportedSocketOptions;
|
|
@@ -4700,6 +5027,7 @@ export declare interface TopologyOptions extends BSONSerializeOptions, ServerOpt
|
|
|
4700
5027
|
/* Excluded from this release type: srvPoller */
|
|
4701
5028
|
/** Indicates that a client should directly connect to a node without attempting to discover its topology type */
|
|
4702
5029
|
directConnection: boolean;
|
|
5030
|
+
loadBalanced: boolean;
|
|
4703
5031
|
metadata: ClientMetadata;
|
|
4704
5032
|
/** MongoDB server API version */
|
|
4705
5033
|
serverApi?: ServerApi;
|
|
@@ -4715,6 +5043,7 @@ export declare const TopologyType: Readonly<{
|
|
|
4715
5043
|
readonly ReplicaSetWithPrimary: "ReplicaSetWithPrimary";
|
|
4716
5044
|
readonly Sharded: "Sharded";
|
|
4717
5045
|
readonly Unknown: "Unknown";
|
|
5046
|
+
readonly LoadBalanced: "LoadBalanced";
|
|
4718
5047
|
}>;
|
|
4719
5048
|
/** @public */
|
|
4720
5049
|
export declare type TopologyType = typeof TopologyType[keyof typeof TopologyType];
|
|
@@ -4742,6 +5071,7 @@ export declare class Transaction {
|
|
|
4742
5071
|
* @returns Whether this session is presently in a transaction
|
|
4743
5072
|
*/
|
|
4744
5073
|
readonly isActive: boolean;
|
|
5074
|
+
readonly isCommitted: boolean;
|
|
4745
5075
|
}
|
|
4746
5076
|
/**
|
|
4747
5077
|
* Configuration options for a transaction.
|
|
@@ -5105,19 +5435,26 @@ export declare class WriteConcern {
|
|
|
5105
5435
|
* @category Error
|
|
5106
5436
|
*/
|
|
5107
5437
|
export declare class WriteConcernError {
|
|
5108
|
-
|
|
5109
|
-
constructor(
|
|
5438
|
+
/* Excluded from this release type: [kServerError] */
|
|
5439
|
+
constructor(error: WriteConcernErrorData);
|
|
5110
5440
|
/*Write concern error code. */
|
|
5111
5441
|
readonly code: number | undefined;
|
|
5112
5442
|
/*Write concern error message. */
|
|
5113
|
-
readonly errmsg: string;
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5443
|
+
readonly errmsg: string | undefined;
|
|
5444
|
+
/*Write concern error info. */
|
|
5445
|
+
readonly errInfo: Document | undefined;
|
|
5446
|
+
/*@deprecated The `err` prop that contained a MongoServerError has been deprecated. */
|
|
5447
|
+
readonly err: WriteConcernErrorData;
|
|
5448
|
+
toJSON(): WriteConcernErrorData;
|
|
5118
5449
|
toString(): string;
|
|
5119
5450
|
}
|
|
5120
5451
|
/** @public */
|
|
5452
|
+
export declare interface WriteConcernErrorData {
|
|
5453
|
+
code: number;
|
|
5454
|
+
errmsg: string;
|
|
5455
|
+
errInfo?: Document;
|
|
5456
|
+
}
|
|
5457
|
+
/** @public */
|
|
5121
5458
|
export declare interface WriteConcernOptions {
|
|
5122
5459
|
/** Write Concern as an object */
|
|
5123
5460
|
writeConcern?: WriteConcern | WriteConcernSettings;
|
|
@@ -5151,6 +5488,8 @@ export declare class WriteError {
|
|
|
5151
5488
|
readonly index: number;
|
|
5152
5489
|
/*WriteError message. */
|
|
5153
5490
|
readonly errmsg: string | undefined;
|
|
5491
|
+
/*WriteError details. */
|
|
5492
|
+
readonly errInfo: Document | undefined;
|
|
5154
5493
|
/** Returns the underlying operation that caused the error */
|
|
5155
5494
|
getOperation(): Document;
|
|
5156
5495
|
toJSON(): {
|