mongodb 4.5.0 → 4.7.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/lib/admin.js +5 -5
- package/lib/admin.js.map +1 -1
- package/lib/bulk/common.js +7 -4
- package/lib/bulk/common.js.map +1 -1
- package/lib/change_stream.js +264 -258
- package/lib/change_stream.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +3 -0
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/scram.js +12 -1
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/commands.js +12 -11
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +8 -1
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +9 -60
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +70 -57
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/cmap/message_stream.js +39 -6
- package/lib/cmap/message_stream.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +18 -2
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +2 -2
- package/lib/cmap/wire_protocol/shared.js +3 -0
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js +62 -31
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +39 -11
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +8 -1
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +16 -11
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +5 -5
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +12 -7
- 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 +6 -1
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js +13 -3
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +37 -24
- package/lib/error.js.map +1 -1
- package/lib/gridfs/upload.js +1 -1
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +18 -0
- package/lib/mongo_client.js.map +1 -1
- package/lib/operations/command.js +0 -3
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/connect.js +1 -0
- package/lib/operations/connect.js.map +1 -1
- package/lib/operations/create_collection.js +56 -17
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/drop.js +48 -7
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js +1 -20
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/execute_operation.js +16 -9
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +0 -51
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/indexes.js +2 -2
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +5 -1
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/list_collections.js +2 -2
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/sdam/monitor.js +10 -3
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +29 -21
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/srv_polling.js +2 -1
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +25 -24
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js +2 -1
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +29 -17
- package/lib/sessions.js.map +1 -1
- package/lib/utils.js +3 -2
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +521 -88
- package/package.json +12 -11
- package/src/admin.ts +9 -5
- package/src/bulk/common.ts +7 -4
- package/src/change_stream.ts +761 -440
- package/src/cmap/auth/mongodb_aws.ts +5 -0
- package/src/cmap/auth/scram.ts +11 -1
- package/src/cmap/commands.ts +23 -22
- package/src/cmap/connect.ts +13 -2
- package/src/cmap/connection.ts +12 -74
- package/src/cmap/connection_pool.ts +90 -74
- package/src/cmap/connection_pool_events.ts +1 -1
- package/src/cmap/message_stream.ts +41 -7
- package/src/cmap/wire_protocol/compression.ts +27 -3
- package/src/cmap/wire_protocol/constants.ts +2 -2
- package/src/cmap/wire_protocol/shared.ts +5 -1
- package/src/collection.ts +74 -36
- package/src/connection_string.ts +49 -14
- package/src/constants.ts +6 -0
- package/src/cursor/abstract_cursor.ts +18 -15
- package/src/cursor/aggregation_cursor.ts +6 -6
- package/src/cursor/find_cursor.ts +16 -8
- package/src/db.ts +31 -20
- package/src/deps.ts +65 -7
- package/src/encrypter.ts +12 -3
- package/src/error.ts +41 -27
- package/src/gridfs/upload.ts +1 -1
- package/src/index.ts +23 -0
- package/src/mongo_client.ts +36 -11
- package/src/mongo_types.ts +1 -1
- package/src/operations/command.ts +0 -4
- package/src/operations/connect.ts +1 -0
- package/src/operations/create_collection.ts +95 -21
- package/src/operations/drop.ts +66 -6
- package/src/operations/estimated_document_count.ts +2 -29
- package/src/operations/execute_operation.ts +27 -27
- package/src/operations/find.ts +0 -80
- package/src/operations/indexes.ts +3 -9
- package/src/operations/insert.ts +8 -1
- package/src/operations/list_collections.ts +3 -3
- package/src/sdam/monitor.ts +10 -0
- package/src/sdam/server.ts +39 -36
- package/src/sdam/srv_polling.ts +1 -0
- package/src/sdam/topology.ts +36 -27
- package/src/sdam/topology_description.ts +2 -1
- package/src/sessions.ts +31 -20
- package/src/transactions.ts +1 -1
- package/src/utils.ts +3 -2
package/mongodb.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
41
41
|
/* Excluded from this release type: [kServer] */
|
|
42
42
|
/* Excluded from this release type: [kNamespace] */
|
|
43
43
|
/* Excluded from this release type: [kDocuments] */
|
|
44
|
-
/* Excluded from this release type: [
|
|
44
|
+
/* Excluded from this release type: [kClient] */
|
|
45
45
|
/* Excluded from this release type: [kTransform] */
|
|
46
46
|
/* Excluded from this release type: [kInitialized] */
|
|
47
47
|
/* Excluded from this release type: [kClosed] */
|
|
@@ -51,7 +51,7 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
51
51
|
static readonly CLOSE: "close";
|
|
52
52
|
/* Excluded from this release type: __constructor */
|
|
53
53
|
get id(): Long | undefined;
|
|
54
|
-
/* Excluded from this release type:
|
|
54
|
+
/* Excluded from this release type: client */
|
|
55
55
|
/* Excluded from this release type: server */
|
|
56
56
|
get namespace(): MongoDBNamespace;
|
|
57
57
|
get readPreference(): ReadPreference;
|
|
@@ -67,7 +67,7 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
67
67
|
/** Returns current buffered documents */
|
|
68
68
|
readBufferedDocuments(number?: number): TSchema[];
|
|
69
69
|
[Symbol.asyncIterator](): AsyncIterator<TSchema, void>;
|
|
70
|
-
stream(options?: CursorStreamOptions): Readable
|
|
70
|
+
stream(options?: CursorStreamOptions): Readable & AsyncIterable<TSchema>;
|
|
71
71
|
hasNext(): Promise<boolean>;
|
|
72
72
|
hasNext(callback: Callback<boolean>): void;
|
|
73
73
|
/** Get the next available document from the cursor, returns null if no more documents are available. */
|
|
@@ -87,7 +87,7 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
87
87
|
*/
|
|
88
88
|
forEach(iterator: (doc: TSchema) => boolean | void): Promise<void>;
|
|
89
89
|
forEach(iterator: (doc: TSchema) => boolean | void, callback: Callback<void>): void;
|
|
90
|
-
close(): void
|
|
90
|
+
close(): Promise<void>;
|
|
91
91
|
close(callback: Callback): void;
|
|
92
92
|
/**
|
|
93
93
|
* @deprecated options argument is deprecated
|
|
@@ -555,7 +555,8 @@ export declare interface AutoEncrypter {
|
|
|
555
555
|
teardown(force: boolean, callback: Callback): void;
|
|
556
556
|
encrypt(ns: string, cmd: Document, options: any, callback: Callback<Document>): void;
|
|
557
557
|
decrypt(cmd: Document, options: any, callback: Callback<Document>): void;
|
|
558
|
-
|
|
558
|
+
/** @experimental */
|
|
559
|
+
readonly cryptSharedLibVersionInfo: {
|
|
559
560
|
version: bigint;
|
|
560
561
|
versionStr: string;
|
|
561
562
|
} | null;
|
|
@@ -652,8 +653,12 @@ export declare interface AutoEncryptionOptions {
|
|
|
652
653
|
* Other validation rules in the JSON schema will not be enforced by the driver and will result in an error.
|
|
653
654
|
*/
|
|
654
655
|
schemaMap?: Document;
|
|
656
|
+
/** @experimental */
|
|
657
|
+
encryptedFieldsMap?: Document;
|
|
655
658
|
/** Allows the user to bypass auto encryption, maintaining implicit decryption */
|
|
656
659
|
bypassAutoEncryption?: boolean;
|
|
660
|
+
/** @experimental */
|
|
661
|
+
bypassQueryAnalysis?: boolean;
|
|
657
662
|
options?: {
|
|
658
663
|
/** An optional hook to catch logging messages from the underlying encryption engine */
|
|
659
664
|
logger?: (level: AutoEncryptionLoggerLevel, message: string) => void;
|
|
@@ -671,15 +676,39 @@ export declare interface AutoEncryptionOptions {
|
|
|
671
676
|
/** Command line arguments to use when auto-spawning a mongocryptd */
|
|
672
677
|
mongocryptdSpawnArgs?: string[];
|
|
673
678
|
/**
|
|
674
|
-
* Full path to a
|
|
675
|
-
*
|
|
679
|
+
* Full path to a MongoDB Crypt shared library to be used (instead of mongocryptd).
|
|
680
|
+
*
|
|
681
|
+
* This needs to be the path to the file itself, not a directory.
|
|
682
|
+
* It can be an absolute or relative path. If the path is relative and
|
|
683
|
+
* its first component is `$ORIGIN`, it will be replaced by the directory
|
|
684
|
+
* containing the mongodb-client-encryption native addon file. Otherwise,
|
|
685
|
+
* the path will be interpreted relative to the current working directory.
|
|
686
|
+
*
|
|
687
|
+
* Currently, loading different MongoDB Crypt shared library files from different
|
|
688
|
+
* MongoClients in the same process is not supported.
|
|
689
|
+
*
|
|
690
|
+
* If this option is provided and no MongoDB Crypt shared library could be loaded
|
|
691
|
+
* from the specified location, creating the MongoClient will fail.
|
|
692
|
+
*
|
|
693
|
+
* If this option is not provided and `cryptSharedLibRequired` is not specified,
|
|
694
|
+
* the AutoEncrypter will attempt to spawn and/or use mongocryptd according
|
|
695
|
+
* to the mongocryptd-specific `extraOptions` options.
|
|
696
|
+
*
|
|
697
|
+
* Specifying a path prevents mongocryptd from being used as a fallback.
|
|
698
|
+
*
|
|
699
|
+
* @experimental Requires the MongoDB Crypt shared library, available in MongoDB 6.0 or higher.
|
|
676
700
|
*/
|
|
677
|
-
|
|
701
|
+
cryptSharedLibPath?: string;
|
|
678
702
|
/**
|
|
679
|
-
*
|
|
680
|
-
*
|
|
703
|
+
* If specified, never use mongocryptd and instead fail when the MongoDB Crypt
|
|
704
|
+
* shared library could not be loaded.
|
|
705
|
+
*
|
|
706
|
+
* This is always true when `cryptSharedLibPath` is specified.
|
|
707
|
+
*
|
|
708
|
+
* @experimental Requires the MongoDB Crypt shared library, available in MongoDB 6.0 or higher.
|
|
681
709
|
*/
|
|
682
|
-
|
|
710
|
+
cryptSharedLibRequired?: boolean;
|
|
711
|
+
/* Excluded from this release type: cryptSharedLibSearchPaths */
|
|
683
712
|
};
|
|
684
713
|
proxyOptions?: ProxyOptions;
|
|
685
714
|
/** The TLS options to use connecting to the KMS provider */
|
|
@@ -985,7 +1014,7 @@ export declare class CancellationToken extends TypedEventEmitter<{
|
|
|
985
1014
|
* Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.
|
|
986
1015
|
* @public
|
|
987
1016
|
*/
|
|
988
|
-
export declare class ChangeStream<TSchema extends Document = Document
|
|
1017
|
+
export declare class ChangeStream<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>> extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>> {
|
|
989
1018
|
pipeline: Document[];
|
|
990
1019
|
options: ChangeStreamOptions;
|
|
991
1020
|
parent: MongoClient | Db | Collection;
|
|
@@ -1029,8 +1058,8 @@ export declare class ChangeStream<TSchema extends Document = Document> extends T
|
|
|
1029
1058
|
hasNext(): Promise<boolean>;
|
|
1030
1059
|
hasNext(callback: Callback<boolean>): void;
|
|
1031
1060
|
/** Get the next available document from the Change Stream. */
|
|
1032
|
-
next(): Promise<
|
|
1033
|
-
next(callback: Callback<
|
|
1061
|
+
next(): Promise<TChange>;
|
|
1062
|
+
next(callback: Callback<TChange>): void;
|
|
1034
1063
|
/** Is the cursor closed */
|
|
1035
1064
|
get closed(): boolean;
|
|
1036
1065
|
/** Close the Change Stream */
|
|
@@ -1039,100 +1068,381 @@ export declare class ChangeStream<TSchema extends Document = Document> extends T
|
|
|
1039
1068
|
* Return a modified Readable stream including a possible transform method.
|
|
1040
1069
|
* @throws MongoDriverError if this.cursor is undefined
|
|
1041
1070
|
*/
|
|
1042
|
-
stream(options?: CursorStreamOptions): Readable
|
|
1071
|
+
stream(options?: CursorStreamOptions): Readable & AsyncIterable<TChange>;
|
|
1043
1072
|
/**
|
|
1044
1073
|
* Try to get the next available document from the Change Stream's cursor or `null` if an empty batch is returned
|
|
1045
1074
|
*/
|
|
1046
1075
|
tryNext(): Promise<Document | null>;
|
|
1047
1076
|
tryNext(callback: Callback<Document | null>): void;
|
|
1077
|
+
/* Excluded from this release type: _setIsEmitter */
|
|
1078
|
+
/* Excluded from this release type: _setIsIterator */
|
|
1079
|
+
/* Excluded from this release type: _createChangeStreamCursor */
|
|
1080
|
+
/* Excluded from this release type: _waitForTopologyConnected */
|
|
1081
|
+
/* Excluded from this release type: _closeWithError */
|
|
1082
|
+
/* Excluded from this release type: _streamEvents */
|
|
1083
|
+
/* Excluded from this release type: _endStream */
|
|
1084
|
+
/* Excluded from this release type: _processNewChange */
|
|
1085
|
+
/* Excluded from this release type: _processError */
|
|
1086
|
+
/* Excluded from this release type: _getCursor */
|
|
1087
|
+
/* Excluded from this release type: _processResumeQueue */
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/* Excluded from this release type: ChangeStreamAggregateRawResult */
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Only present when the `showExpandedEvents` flag is enabled.
|
|
1094
|
+
* @public
|
|
1095
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/
|
|
1096
|
+
*/
|
|
1097
|
+
export declare interface ChangeStreamCollModDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID {
|
|
1098
|
+
/** Describes the type of operation represented in this change notification */
|
|
1099
|
+
operationType: 'modify';
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* @public
|
|
1104
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/
|
|
1105
|
+
*/
|
|
1106
|
+
export declare interface ChangeStreamCreateDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID {
|
|
1107
|
+
/** Describes the type of operation represented in this change notification */
|
|
1108
|
+
operationType: 'create';
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Only present when the `showExpandedEvents` flag is enabled.
|
|
1113
|
+
* @public
|
|
1114
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/
|
|
1115
|
+
*/
|
|
1116
|
+
export declare interface ChangeStreamCreateIndexDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID, ChangeStreamDocumentOperationDescription {
|
|
1117
|
+
/** Describes the type of operation represented in this change notification */
|
|
1118
|
+
operationType: 'createIndexes';
|
|
1048
1119
|
}
|
|
1049
1120
|
|
|
1050
1121
|
/* Excluded from this release type: ChangeStreamCursor */
|
|
1051
1122
|
|
|
1052
1123
|
/* Excluded from this release type: ChangeStreamCursorOptions */
|
|
1053
1124
|
|
|
1125
|
+
/**
|
|
1126
|
+
* @public
|
|
1127
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#delete-event
|
|
1128
|
+
*/
|
|
1129
|
+
export declare interface ChangeStreamDeleteDocument<TSchema extends Document = Document> extends ChangeStreamDocumentCommon, ChangeStreamDocumentKey<TSchema>, ChangeStreamDocumentCollectionUUID {
|
|
1130
|
+
/** Describes the type of operation represented in this change notification */
|
|
1131
|
+
operationType: 'delete';
|
|
1132
|
+
/** Namespace the delete event occured on */
|
|
1133
|
+
ns: ChangeStreamNameSpace;
|
|
1134
|
+
/**
|
|
1135
|
+
* Contains the pre-image of the modified or deleted document if the
|
|
1136
|
+
* pre-image is available for the change event and either 'required' or
|
|
1137
|
+
* 'whenAvailable' was specified for the 'fullDocumentBeforeChange' option
|
|
1138
|
+
* when creating the change stream. If 'whenAvailable' was specified but the
|
|
1139
|
+
* pre-image is unavailable, this will be explicitly set to null.
|
|
1140
|
+
*/
|
|
1141
|
+
fullDocumentBeforeChange?: TSchema;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/** @public */
|
|
1145
|
+
export declare type ChangeStreamDocument<TSchema extends Document = Document> = ChangeStreamInsertDocument<TSchema> | ChangeStreamUpdateDocument<TSchema> | ChangeStreamReplaceDocument<TSchema> | ChangeStreamDeleteDocument<TSchema> | ChangeStreamDropDocument | ChangeStreamRenameDocument | ChangeStreamDropDatabaseDocument | ChangeStreamInvalidateDocument | ChangeStreamCreateIndexDocument | ChangeStreamCreateDocument | ChangeStreamCollModDocument | ChangeStreamDropIndexDocument | ChangeStreamShardCollectionDocument | ChangeStreamReshardCollectionDocument | ChangeStreamRefineCollectionShardKeyDocument;
|
|
1146
|
+
|
|
1147
|
+
/** @public */
|
|
1148
|
+
export declare interface ChangeStreamDocumentCollectionUUID {
|
|
1149
|
+
/**
|
|
1150
|
+
* The UUID (Binary subtype 4) of the collection that the operation was performed on.
|
|
1151
|
+
*
|
|
1152
|
+
* Only present when the `showExpandedEvents` flag is enabled.
|
|
1153
|
+
*
|
|
1154
|
+
* **NOTE:** collectionUUID will be converted to a NodeJS Buffer if the promoteBuffers
|
|
1155
|
+
* flag is enabled.
|
|
1156
|
+
*
|
|
1157
|
+
* @since 6.1.0
|
|
1158
|
+
*/
|
|
1159
|
+
collectionUUID: Binary;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1054
1162
|
/** @public */
|
|
1055
|
-
export declare interface
|
|
1163
|
+
export declare interface ChangeStreamDocumentCommon {
|
|
1056
1164
|
/**
|
|
1057
1165
|
* The id functions as an opaque token for use when resuming an interrupted
|
|
1058
1166
|
* change stream.
|
|
1059
1167
|
*/
|
|
1060
|
-
_id:
|
|
1168
|
+
_id: ResumeToken;
|
|
1061
1169
|
/**
|
|
1062
|
-
*
|
|
1170
|
+
* The timestamp from the oplog entry associated with the event.
|
|
1171
|
+
* For events that happened as part of a multi-document transaction, the associated change stream
|
|
1172
|
+
* notifications will have the same clusterTime value, namely the time when the transaction was committed.
|
|
1173
|
+
* On a sharded cluster, events that occur on different shards can have the same clusterTime but be
|
|
1174
|
+
* associated with different transactions or even not be associated with any transaction.
|
|
1175
|
+
* To identify events for a single transaction, you can use the combination of lsid and txnNumber in the change stream event document.
|
|
1063
1176
|
*/
|
|
1064
|
-
|
|
1177
|
+
clusterTime?: Timestamp;
|
|
1065
1178
|
/**
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1179
|
+
* The transaction number.
|
|
1180
|
+
* Only present if the operation is part of a multi-document transaction.
|
|
1181
|
+
*
|
|
1182
|
+
* **NOTE:** txnNumber can be a Long if promoteLongs is set to false
|
|
1068
1183
|
*/
|
|
1069
|
-
|
|
1070
|
-
db: string;
|
|
1071
|
-
coll: string;
|
|
1072
|
-
};
|
|
1184
|
+
txnNumber?: number;
|
|
1073
1185
|
/**
|
|
1074
|
-
*
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1077
|
-
* For unsharded collections this contains a single field, _id, with the
|
|
1078
|
-
* value of the _id of the document updated. For sharded collections,
|
|
1079
|
-
* this will contain all the components of the shard key in order,
|
|
1080
|
-
* followed by the _id if the _id isn’t part of the shard key.
|
|
1186
|
+
* The identifier for the session associated with the transaction.
|
|
1187
|
+
* Only present if the operation is part of a multi-document transaction.
|
|
1081
1188
|
*/
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1189
|
+
lsid?: ServerSessionId;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
/** @public */
|
|
1193
|
+
export declare interface ChangeStreamDocumentKey<TSchema extends Document = Document> {
|
|
1085
1194
|
/**
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
* Contains a description of updated and removed fields in this
|
|
1089
|
-
* operation.
|
|
1195
|
+
* For unsharded collections this contains a single field `_id`.
|
|
1196
|
+
* For sharded collections, this will contain all the components of the shard key
|
|
1090
1197
|
*/
|
|
1091
|
-
|
|
1198
|
+
documentKey: {
|
|
1199
|
+
_id: InferIdType<TSchema>;
|
|
1200
|
+
[shardKey: string]: any;
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/** @public */
|
|
1205
|
+
export declare interface ChangeStreamDocumentOperationDescription {
|
|
1092
1206
|
/**
|
|
1093
|
-
*
|
|
1094
|
-
* present for operations of type ‘update’ if the user has specified ‘updateLookup’
|
|
1095
|
-
* in the ‘fullDocument’ arguments to the ‘$changeStream’ stage.
|
|
1207
|
+
* An description of the operation.
|
|
1096
1208
|
*
|
|
1097
|
-
*
|
|
1098
|
-
* document being inserted, or the new version of the document that is replacing
|
|
1099
|
-
* the existing document, respectively.
|
|
1209
|
+
* Only present when the `showExpandedEvents` flag is enabled.
|
|
1100
1210
|
*
|
|
1101
|
-
*
|
|
1102
|
-
* version of the document from some point after the update occurred. If the
|
|
1103
|
-
* document was deleted since the updated happened, it will be null.
|
|
1211
|
+
* @since 6.1.0
|
|
1104
1212
|
*/
|
|
1105
|
-
|
|
1213
|
+
operationDescription?: Document;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* @public
|
|
1218
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#dropdatabase-event
|
|
1219
|
+
*/
|
|
1220
|
+
export declare interface ChangeStreamDropDatabaseDocument extends ChangeStreamDocumentCommon {
|
|
1221
|
+
/** Describes the type of operation represented in this change notification */
|
|
1222
|
+
operationType: 'dropDatabase';
|
|
1223
|
+
/** The database dropped */
|
|
1224
|
+
ns: {
|
|
1225
|
+
db: string;
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* @public
|
|
1231
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#drop-event
|
|
1232
|
+
*/
|
|
1233
|
+
export declare interface ChangeStreamDropDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID {
|
|
1234
|
+
/** Describes the type of operation represented in this change notification */
|
|
1235
|
+
operationType: 'drop';
|
|
1236
|
+
/** Namespace the drop event occured on */
|
|
1237
|
+
ns: ChangeStreamNameSpace;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Only present when the `showExpandedEvents` flag is enabled.
|
|
1242
|
+
* @public
|
|
1243
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/
|
|
1244
|
+
*/
|
|
1245
|
+
export declare interface ChangeStreamDropIndexDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID, ChangeStreamDocumentOperationDescription {
|
|
1246
|
+
/** Describes the type of operation represented in this change notification */
|
|
1247
|
+
operationType: 'dropIndexes';
|
|
1106
1248
|
}
|
|
1107
1249
|
|
|
1108
1250
|
/** @public */
|
|
1109
|
-
export declare type ChangeStreamEvents<TSchema extends Document = Document
|
|
1251
|
+
export declare type ChangeStreamEvents<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>> = {
|
|
1110
1252
|
resumeTokenChanged(token: ResumeToken): void;
|
|
1111
|
-
init(response:
|
|
1112
|
-
more(response?:
|
|
1253
|
+
init(response: any): void;
|
|
1254
|
+
more(response?: any): void;
|
|
1113
1255
|
response(): void;
|
|
1114
1256
|
end(): void;
|
|
1115
1257
|
error(error: Error): void;
|
|
1116
|
-
change(change:
|
|
1258
|
+
change(change: TChange): void;
|
|
1117
1259
|
} & AbstractCursorEvents;
|
|
1118
1260
|
|
|
1261
|
+
/**
|
|
1262
|
+
* @public
|
|
1263
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#insert-event
|
|
1264
|
+
*/
|
|
1265
|
+
export declare interface ChangeStreamInsertDocument<TSchema extends Document = Document> extends ChangeStreamDocumentCommon, ChangeStreamDocumentKey<TSchema>, ChangeStreamDocumentCollectionUUID {
|
|
1266
|
+
/** Describes the type of operation represented in this change notification */
|
|
1267
|
+
operationType: 'insert';
|
|
1268
|
+
/** This key will contain the document being inserted */
|
|
1269
|
+
fullDocument: TSchema;
|
|
1270
|
+
/** Namespace the insert event occured on */
|
|
1271
|
+
ns: ChangeStreamNameSpace;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* @public
|
|
1276
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
|
|
1277
|
+
*/
|
|
1278
|
+
export declare interface ChangeStreamInvalidateDocument extends ChangeStreamDocumentCommon {
|
|
1279
|
+
/** Describes the type of operation represented in this change notification */
|
|
1280
|
+
operationType: 'invalidate';
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** @public */
|
|
1284
|
+
export declare interface ChangeStreamNameSpace {
|
|
1285
|
+
db: string;
|
|
1286
|
+
coll: string;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1119
1289
|
/**
|
|
1120
1290
|
* Options that can be passed to a ChangeStream. Note that startAfter, resumeAfter, and startAtOperationTime are all mutually exclusive, and the server will error if more than one is specified.
|
|
1121
1291
|
* @public
|
|
1122
1292
|
*/
|
|
1123
1293
|
export declare interface ChangeStreamOptions extends AggregateOptions {
|
|
1124
|
-
/**
|
|
1294
|
+
/**
|
|
1295
|
+
* Allowed values: 'updateLookup', 'whenAvailable', 'required'.
|
|
1296
|
+
*
|
|
1297
|
+
* When set to 'updateLookup', the change notification for partial updates
|
|
1298
|
+
* will include both a delta describing the changes to the document as well
|
|
1299
|
+
* as a copy of the entire document that was changed from some time after
|
|
1300
|
+
* the change occurred.
|
|
1301
|
+
*
|
|
1302
|
+
* When set to 'whenAvailable', configures the change stream to return the
|
|
1303
|
+
* post-image of the modified document for replace and update change events
|
|
1304
|
+
* if the post-image for this event is available.
|
|
1305
|
+
*
|
|
1306
|
+
* When set to 'required', the same behavior as 'whenAvailable' except that
|
|
1307
|
+
* an error is raised if the post-image is not available.
|
|
1308
|
+
*/
|
|
1125
1309
|
fullDocument?: string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Allowed values: 'whenAvailable', 'required', 'off'.
|
|
1312
|
+
*
|
|
1313
|
+
* The default is to not send a value, which is equivalent to 'off'.
|
|
1314
|
+
*
|
|
1315
|
+
* When set to 'whenAvailable', configures the change stream to return the
|
|
1316
|
+
* pre-image of the modified document for replace, update, and delete change
|
|
1317
|
+
* events if it is available.
|
|
1318
|
+
*
|
|
1319
|
+
* When set to 'required', the same behavior as 'whenAvailable' except that
|
|
1320
|
+
* an error is raised if the pre-image is not available.
|
|
1321
|
+
*/
|
|
1322
|
+
fullDocumentBeforeChange?: string;
|
|
1126
1323
|
/** The maximum amount of time for the server to wait on new documents to satisfy a change stream query. */
|
|
1127
1324
|
maxAwaitTimeMS?: number;
|
|
1128
|
-
/**
|
|
1325
|
+
/**
|
|
1326
|
+
* Allows you to start a changeStream after a specified event.
|
|
1327
|
+
* @see https://docs.mongodb.com/manual/changeStreams/#resumeafter-for-change-streams
|
|
1328
|
+
*/
|
|
1129
1329
|
resumeAfter?: ResumeToken;
|
|
1130
|
-
/**
|
|
1330
|
+
/**
|
|
1331
|
+
* Similar to resumeAfter, but will allow you to start after an invalidated event.
|
|
1332
|
+
* @see https://docs.mongodb.com/manual/changeStreams/#startafter-for-change-streams
|
|
1333
|
+
*/
|
|
1131
1334
|
startAfter?: ResumeToken;
|
|
1132
1335
|
/** Will start the changeStream after the specified operationTime. */
|
|
1133
1336
|
startAtOperationTime?: OperationTime;
|
|
1134
|
-
/**
|
|
1337
|
+
/**
|
|
1338
|
+
* The number of documents to return per batch.
|
|
1339
|
+
* @see https://docs.mongodb.com/manual/reference/command/aggregate
|
|
1340
|
+
*/
|
|
1135
1341
|
batchSize?: number;
|
|
1342
|
+
/**
|
|
1343
|
+
* When enabled, configures the change stream to include extra change events.
|
|
1344
|
+
*
|
|
1345
|
+
* - createIndexes
|
|
1346
|
+
* - dropIndexes
|
|
1347
|
+
* - modify
|
|
1348
|
+
* - create
|
|
1349
|
+
* - shardCollection
|
|
1350
|
+
* - reshardCollection
|
|
1351
|
+
* - refineCollectionShardKey
|
|
1352
|
+
*/
|
|
1353
|
+
showExpandedEvents?: boolean;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* @public
|
|
1358
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/
|
|
1359
|
+
*/
|
|
1360
|
+
export declare interface ChangeStreamRefineCollectionShardKeyDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID, ChangeStreamDocumentOperationDescription {
|
|
1361
|
+
/** Describes the type of operation represented in this change notification */
|
|
1362
|
+
operationType: 'refineCollectionShardKey';
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* @public
|
|
1367
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#rename-event
|
|
1368
|
+
*/
|
|
1369
|
+
export declare interface ChangeStreamRenameDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID {
|
|
1370
|
+
/** Describes the type of operation represented in this change notification */
|
|
1371
|
+
operationType: 'rename';
|
|
1372
|
+
/** The new name for the `ns.coll` collection */
|
|
1373
|
+
to: {
|
|
1374
|
+
db: string;
|
|
1375
|
+
coll: string;
|
|
1376
|
+
};
|
|
1377
|
+
/** The "from" namespace that the rename occured on */
|
|
1378
|
+
ns: ChangeStreamNameSpace;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* @public
|
|
1383
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#replace-event
|
|
1384
|
+
*/
|
|
1385
|
+
export declare interface ChangeStreamReplaceDocument<TSchema extends Document = Document> extends ChangeStreamDocumentCommon, ChangeStreamDocumentKey<TSchema> {
|
|
1386
|
+
/** Describes the type of operation represented in this change notification */
|
|
1387
|
+
operationType: 'replace';
|
|
1388
|
+
/** The fullDocument of a replace event represents the document after the insert of the replacement document */
|
|
1389
|
+
fullDocument: TSchema;
|
|
1390
|
+
/** Namespace the replace event occured on */
|
|
1391
|
+
ns: ChangeStreamNameSpace;
|
|
1392
|
+
/**
|
|
1393
|
+
* Contains the pre-image of the modified or deleted document if the
|
|
1394
|
+
* pre-image is available for the change event and either 'required' or
|
|
1395
|
+
* 'whenAvailable' was specified for the 'fullDocumentBeforeChange' option
|
|
1396
|
+
* when creating the change stream. If 'whenAvailable' was specified but the
|
|
1397
|
+
* pre-image is unavailable, this will be explicitly set to null.
|
|
1398
|
+
*/
|
|
1399
|
+
fullDocumentBeforeChange?: TSchema;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* @public
|
|
1404
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/
|
|
1405
|
+
*/
|
|
1406
|
+
export declare interface ChangeStreamReshardCollectionDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID, ChangeStreamDocumentOperationDescription {
|
|
1407
|
+
/** Describes the type of operation represented in this change notification */
|
|
1408
|
+
operationType: 'reshardCollection';
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* @public
|
|
1413
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/
|
|
1414
|
+
*/
|
|
1415
|
+
export declare interface ChangeStreamShardCollectionDocument extends ChangeStreamDocumentCommon, ChangeStreamDocumentCollectionUUID, ChangeStreamDocumentOperationDescription {
|
|
1416
|
+
/** Describes the type of operation represented in this change notification */
|
|
1417
|
+
operationType: 'shardCollection';
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* @public
|
|
1422
|
+
* @see https://www.mongodb.com/docs/manual/reference/change-events/#update-event
|
|
1423
|
+
*/
|
|
1424
|
+
export declare interface ChangeStreamUpdateDocument<TSchema extends Document = Document> extends ChangeStreamDocumentCommon, ChangeStreamDocumentKey<TSchema>, ChangeStreamDocumentCollectionUUID {
|
|
1425
|
+
/** Describes the type of operation represented in this change notification */
|
|
1426
|
+
operationType: 'update';
|
|
1427
|
+
/**
|
|
1428
|
+
* This is only set if `fullDocument` is set to `'updateLookup'`
|
|
1429
|
+
* Contains the point-in-time post-image of the modified document if the
|
|
1430
|
+
* post-image is available and either 'required' or 'whenAvailable' was
|
|
1431
|
+
* specified for the 'fullDocument' option when creating the change stream.
|
|
1432
|
+
*/
|
|
1433
|
+
fullDocument?: TSchema;
|
|
1434
|
+
/** Contains a description of updated and removed fields in this operation */
|
|
1435
|
+
updateDescription: UpdateDescription<TSchema>;
|
|
1436
|
+
/** Namespace the update event occured on */
|
|
1437
|
+
ns: ChangeStreamNameSpace;
|
|
1438
|
+
/**
|
|
1439
|
+
* Contains the pre-image of the modified or deleted document if the
|
|
1440
|
+
* pre-image is available for the change event and either 'required' or
|
|
1441
|
+
* 'whenAvailable' was specified for the 'fullDocumentBeforeChange' option
|
|
1442
|
+
* when creating the change stream. If 'whenAvailable' was specified but the
|
|
1443
|
+
* pre-image is unavailable, this will be explicitly set to null.
|
|
1444
|
+
*/
|
|
1445
|
+
fullDocumentBeforeChange?: TSchema;
|
|
1136
1446
|
}
|
|
1137
1447
|
|
|
1138
1448
|
/** @public */
|
|
@@ -1171,7 +1481,7 @@ export declare interface ClientMetadataOptions {
|
|
|
1171
1481
|
* @public
|
|
1172
1482
|
*/
|
|
1173
1483
|
export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
|
|
1174
|
-
/* Excluded from this release type:
|
|
1484
|
+
/* Excluded from this release type: client */
|
|
1175
1485
|
/* Excluded from this release type: sessionPool */
|
|
1176
1486
|
hasEnded: boolean;
|
|
1177
1487
|
clientOptions?: MongoOptions;
|
|
@@ -1264,17 +1574,27 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
1264
1574
|
*/
|
|
1265
1575
|
toBSON(): never;
|
|
1266
1576
|
/**
|
|
1267
|
-
* Runs a provided
|
|
1577
|
+
* Runs a provided callback within a transaction, retrying either the commitTransaction operation
|
|
1268
1578
|
* or entire transaction as needed (and when the error permits) to better ensure that
|
|
1269
1579
|
* the transaction can complete successfully.
|
|
1270
1580
|
*
|
|
1271
|
-
* IMPORTANT
|
|
1272
|
-
* return a Promise will result in undefined behavior.
|
|
1581
|
+
* **IMPORTANT:** This method requires the user to return a Promise, and `await` all operations.
|
|
1582
|
+
* Any callbacks that do not return a Promise will result in undefined behavior.
|
|
1273
1583
|
*
|
|
1274
|
-
* @
|
|
1275
|
-
*
|
|
1584
|
+
* @remarks
|
|
1585
|
+
* This function:
|
|
1586
|
+
* - Will return the command response from the final commitTransaction if every operation is successful (can be used as a truthy object)
|
|
1587
|
+
* - Will return `undefined` if the transaction is explicitly aborted with `await session.abortTransaction()`
|
|
1588
|
+
* - Will throw if one of the operations throws or `throw` statement is used inside the `withTransaction` callback
|
|
1589
|
+
*
|
|
1590
|
+
* Checkout a descriptive example here:
|
|
1591
|
+
* @see https://www.mongodb.com/developer/quickstart/node-transactions/
|
|
1592
|
+
*
|
|
1593
|
+
* @param fn - callback to run within a transaction
|
|
1594
|
+
* @param options - optional settings for the transaction
|
|
1595
|
+
* @returns A raw command response or undefined
|
|
1276
1596
|
*/
|
|
1277
|
-
withTransaction<T = void>(fn: WithTransactionCallback<T>, options?: TransactionOptions):
|
|
1597
|
+
withTransaction<T = void>(fn: WithTransactionCallback<T>, options?: TransactionOptions): Promise<Document | undefined>;
|
|
1278
1598
|
}
|
|
1279
1599
|
|
|
1280
1600
|
/** @public */
|
|
@@ -1300,6 +1620,17 @@ export declare interface CloseOptions {
|
|
|
1300
1620
|
force?: boolean;
|
|
1301
1621
|
}
|
|
1302
1622
|
|
|
1623
|
+
/** @public
|
|
1624
|
+
* Configuration options for clustered collections
|
|
1625
|
+
* TODO: NODE-4230 replace with normal manual link once it is on there.
|
|
1626
|
+
* @see https://www.mongodb.com/docs/v5.3/core/clustered-collections/
|
|
1627
|
+
*/
|
|
1628
|
+
export declare interface ClusteredCollectionOptions extends Document {
|
|
1629
|
+
name?: string;
|
|
1630
|
+
key: Document;
|
|
1631
|
+
unique: boolean;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1303
1634
|
/** @public */
|
|
1304
1635
|
export declare interface ClusterTime {
|
|
1305
1636
|
clusterTime: Timestamp;
|
|
@@ -1694,7 +2025,15 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
1694
2025
|
indexInformation(options: IndexInformationOptions, callback: Callback<Document>): void;
|
|
1695
2026
|
/**
|
|
1696
2027
|
* Gets an estimate of the count of documents in a collection using collection metadata.
|
|
2028
|
+
* This will always run a count command on all server versions.
|
|
1697
2029
|
*
|
|
2030
|
+
* due to an oversight in versions 5.0.0-5.0.8 of MongoDB, the count command,
|
|
2031
|
+
* which estimatedDocumentCount uses in its implementation, was not included in v1 of
|
|
2032
|
+
* the Stable API, and so users of the Stable API with estimatedDocumentCount are
|
|
2033
|
+
* recommended to upgrade their server version to 5.0.9+ or set apiStrict: false to avoid
|
|
2034
|
+
* encountering errors.
|
|
2035
|
+
*
|
|
2036
|
+
* @see {@link https://www.mongodb.com/docs/manual/reference/command/count/#behavior|Count: Behavior}
|
|
1698
2037
|
* @param options - Optional settings for the command
|
|
1699
2038
|
* @param callback - An optional callback, a Promise will be returned if none is provided
|
|
1700
2039
|
*/
|
|
@@ -1820,11 +2159,42 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
1820
2159
|
/**
|
|
1821
2160
|
* Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.
|
|
1822
2161
|
*
|
|
1823
|
-
* @
|
|
2162
|
+
* @remarks
|
|
2163
|
+
* watch() accepts two generic arguments for distinct usecases:
|
|
2164
|
+
* - The first is to override the schema that may be defined for this specific collection
|
|
2165
|
+
* - 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
|
|
2166
|
+
* @example
|
|
2167
|
+
* By just providing the first argument I can type the change to be `ChangeStreamDocument<{ _id: number }>`
|
|
2168
|
+
* ```ts
|
|
2169
|
+
* collection.watch<{ _id: number }>()
|
|
2170
|
+
* .on('change', change => console.log(change._id.toFixed(4)));
|
|
2171
|
+
* ```
|
|
2172
|
+
*
|
|
2173
|
+
* @example
|
|
2174
|
+
* Passing a second argument provides a way to reflect the type changes caused by an advanced pipeline.
|
|
2175
|
+
* Here, we are using a pipeline to have MongoDB filter for insert changes only and add a comment.
|
|
2176
|
+
* No need start from scratch on the ChangeStreamInsertDocument type!
|
|
2177
|
+
* By using an intersection we can save time and ensure defaults remain the same type!
|
|
2178
|
+
* ```ts
|
|
2179
|
+
* collection
|
|
2180
|
+
* .watch<Schema, ChangeStreamInsertDocument<Schema> & { comment: string }>([
|
|
2181
|
+
* { $addFields: { comment: 'big changes' } },
|
|
2182
|
+
* { $match: { operationType: 'insert' } }
|
|
2183
|
+
* ])
|
|
2184
|
+
* .on('change', change => {
|
|
2185
|
+
* change.comment.startsWith('big');
|
|
2186
|
+
* change.operationType === 'insert';
|
|
2187
|
+
* // No need to narrow in code because the generics did that for us!
|
|
2188
|
+
* expectType<Schema>(change.fullDocument);
|
|
2189
|
+
* });
|
|
2190
|
+
* ```
|
|
2191
|
+
*
|
|
1824
2192
|
* @param pipeline - An array of {@link https://docs.mongodb.com/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.
|
|
1825
2193
|
* @param options - Optional settings for the command
|
|
2194
|
+
* @typeParam TLocal - Type of the data being detected by the change stream
|
|
2195
|
+
* @typeParam TChange - Type of the whole change stream document emitted
|
|
1826
2196
|
*/
|
|
1827
|
-
watch<TLocal extends Document = TSchema
|
|
2197
|
+
watch<TLocal extends Document = TSchema, TChange extends Document = ChangeStreamDocument<TLocal>>(pipeline?: Document[], options?: ChangeStreamOptions): ChangeStream<TLocal, TChange>;
|
|
1828
2198
|
/**
|
|
1829
2199
|
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
|
|
1830
2200
|
*
|
|
@@ -2070,6 +2440,7 @@ export declare const Compressor: Readonly<{
|
|
|
2070
2440
|
readonly none: 0;
|
|
2071
2441
|
readonly snappy: 1;
|
|
2072
2442
|
readonly zlib: 2;
|
|
2443
|
+
readonly zstd: 3;
|
|
2073
2444
|
}>;
|
|
2074
2445
|
|
|
2075
2446
|
/** @public */
|
|
@@ -2249,6 +2620,8 @@ export declare interface ConnectionPoolOptions extends Omit<ConnectionOptions, '
|
|
|
2249
2620
|
maxPoolSize: number;
|
|
2250
2621
|
/** The minimum number of connections that MUST exist at any moment in a single connection pool. */
|
|
2251
2622
|
minPoolSize: number;
|
|
2623
|
+
/** The maximum number of connections that may be in the process of being established concurrently by the connection pool. */
|
|
2624
|
+
maxConnecting: number;
|
|
2252
2625
|
/** The maximum amount of time a connection should remain idle in the connection pool before being marked idle. */
|
|
2253
2626
|
maxIdleTimeMS: number;
|
|
2254
2627
|
/** 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. */
|
|
@@ -2325,8 +2698,19 @@ export declare interface CreateCollectionOptions extends CommandOperationOptions
|
|
|
2325
2698
|
pkFactory?: PkFactory;
|
|
2326
2699
|
/** A document specifying configuration options for timeseries collections. */
|
|
2327
2700
|
timeseries?: TimeSeriesCollectionOptions;
|
|
2328
|
-
/**
|
|
2701
|
+
/** A document specifying configuration options for clustered collections. For MongoDB 5.3 and above. */
|
|
2702
|
+
clusteredIndex?: ClusteredCollectionOptions;
|
|
2703
|
+
/** The number of seconds after which a document in a timeseries or clustered collection expires. */
|
|
2329
2704
|
expireAfterSeconds?: number;
|
|
2705
|
+
/** @experimental */
|
|
2706
|
+
encryptedFields?: Document;
|
|
2707
|
+
/**
|
|
2708
|
+
* If set, enables pre-update and post-update document events to be included for any
|
|
2709
|
+
* change streams that listen on this collection.
|
|
2710
|
+
*/
|
|
2711
|
+
changeStreamPreAndPostImages?: {
|
|
2712
|
+
enabled: boolean;
|
|
2713
|
+
};
|
|
2330
2714
|
}
|
|
2331
2715
|
|
|
2332
2716
|
/** @public */
|
|
@@ -2631,10 +3015,17 @@ export declare class Db {
|
|
|
2631
3015
|
* replacements, deletions, and invalidations) in this database. Will ignore all
|
|
2632
3016
|
* changes to system collections.
|
|
2633
3017
|
*
|
|
3018
|
+
* @remarks
|
|
3019
|
+
* watch() accepts two generic arguments for distinct usecases:
|
|
3020
|
+
* - The first is to provide the schema that may be defined for all the collections within this database
|
|
3021
|
+
* - 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
|
|
3022
|
+
*
|
|
2634
3023
|
* @param pipeline - An array of {@link https://docs.mongodb.com/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.
|
|
2635
3024
|
* @param options - Optional settings for the command
|
|
3025
|
+
* @typeParam TSchema - Type of the data being detected by the change stream
|
|
3026
|
+
* @typeParam TChange - Type of the whole change stream document emitted
|
|
2636
3027
|
*/
|
|
2637
|
-
watch<TSchema extends Document = Document
|
|
3028
|
+
watch<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>>(pipeline?: Document[], options?: ChangeStreamOptions): ChangeStream<TSchema, TChange>;
|
|
2638
3029
|
/** Return the db logger */
|
|
2639
3030
|
getLogger(): Logger;
|
|
2640
3031
|
get logger(): Logger;
|
|
@@ -2746,7 +3137,10 @@ export declare interface DriverInfo {
|
|
|
2746
3137
|
}
|
|
2747
3138
|
|
|
2748
3139
|
/** @public */
|
|
2749
|
-
export declare
|
|
3140
|
+
export declare interface DropCollectionOptions extends CommandOperationOptions {
|
|
3141
|
+
/** @experimental */
|
|
3142
|
+
encryptedFields?: Document;
|
|
3143
|
+
}
|
|
2750
3144
|
|
|
2751
3145
|
/** @public */
|
|
2752
3146
|
export declare type DropDatabaseOptions = CommandOperationOptions;
|
|
@@ -3022,7 +3416,7 @@ export declare class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
|
|
|
3022
3416
|
* @remarks
|
|
3023
3417
|
* {@link https://docs.mongodb.com/manual/reference/command/find/#find-cmd-allowdiskuse | find command allowDiskUse documentation}
|
|
3024
3418
|
*/
|
|
3025
|
-
allowDiskUse(): this;
|
|
3419
|
+
allowDiskUse(allow?: boolean): this;
|
|
3026
3420
|
/**
|
|
3027
3421
|
* Set the collation options for the cursor.
|
|
3028
3422
|
*
|
|
@@ -3588,6 +3982,8 @@ export declare type Join<T extends unknown[], D extends string> = T extends [] ?
|
|
|
3588
3982
|
|
|
3589
3983
|
/* Excluded from this release type: kCheckedOut */
|
|
3590
3984
|
|
|
3985
|
+
/* Excluded from this release type: kClient */
|
|
3986
|
+
|
|
3591
3987
|
/* Excluded from this release type: kClosed */
|
|
3592
3988
|
|
|
3593
3989
|
/* Excluded from this release type: kClosed_2 */
|
|
@@ -3670,7 +4066,7 @@ export declare type KeysOfOtherType<TSchema, Type> = {
|
|
|
3670
4066
|
|
|
3671
4067
|
/* Excluded from this release type: kOptions_3 */
|
|
3672
4068
|
|
|
3673
|
-
/* Excluded from this release type:
|
|
4069
|
+
/* Excluded from this release type: kPending */
|
|
3674
4070
|
|
|
3675
4071
|
/* Excluded from this release type: kPinnedConnection */
|
|
3676
4072
|
|
|
@@ -3706,8 +4102,6 @@ export declare type KeysOfOtherType<TSchema, Type> = {
|
|
|
3706
4102
|
|
|
3707
4103
|
/* Excluded from this release type: kStream */
|
|
3708
4104
|
|
|
3709
|
-
/* Excluded from this release type: kTopology */
|
|
3710
|
-
|
|
3711
4105
|
/* Excluded from this release type: kTransform */
|
|
3712
4106
|
|
|
3713
4107
|
/* Excluded from this release type: kTxnNumberIncrement */
|
|
@@ -3951,6 +4345,18 @@ export declare class MongoAPIError extends MongoDriverError {
|
|
|
3951
4345
|
get name(): string;
|
|
3952
4346
|
}
|
|
3953
4347
|
|
|
4348
|
+
/**
|
|
4349
|
+
* A error generated when the user attempts to authenticate
|
|
4350
|
+
* via AWS, but fails
|
|
4351
|
+
*
|
|
4352
|
+
* @public
|
|
4353
|
+
* @category Error
|
|
4354
|
+
*/
|
|
4355
|
+
export declare class MongoAWSError extends MongoRuntimeError {
|
|
4356
|
+
constructor(message: string);
|
|
4357
|
+
get name(): string;
|
|
4358
|
+
}
|
|
4359
|
+
|
|
3954
4360
|
/**
|
|
3955
4361
|
* An error generated when a batch command is re-executed after one of the commands in the batch
|
|
3956
4362
|
* has failed
|
|
@@ -4120,10 +4526,17 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> {
|
|
|
4120
4526
|
* replacements, deletions, and invalidations) in this cluster. Will ignore all
|
|
4121
4527
|
* changes to system collections, as well as the local, admin, and config databases.
|
|
4122
4528
|
*
|
|
4529
|
+
* @remarks
|
|
4530
|
+
* watch() accepts two generic arguments for distinct usecases:
|
|
4531
|
+
* - The first is to provide the schema that may be defined for all the data within the current cluster
|
|
4532
|
+
* - 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
|
|
4533
|
+
*
|
|
4123
4534
|
* @param pipeline - An array of {@link https://docs.mongodb.com/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.
|
|
4124
4535
|
* @param options - Optional settings for the command
|
|
4536
|
+
* @typeParam TSchema - Type of the data being detected by the change stream
|
|
4537
|
+
* @typeParam TChange - Type of the whole change stream document emitted
|
|
4125
4538
|
*/
|
|
4126
|
-
watch<TSchema extends Document = Document
|
|
4539
|
+
watch<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>>(pipeline?: Document[], options?: ChangeStreamOptions): ChangeStream<TSchema, TChange>;
|
|
4127
4540
|
/** Return the mongo client logger */
|
|
4128
4541
|
getLogger(): Logger;
|
|
4129
4542
|
}
|
|
@@ -4181,6 +4594,8 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
4181
4594
|
maxPoolSize?: number;
|
|
4182
4595
|
/** The minimum number of connections in the connection pool. */
|
|
4183
4596
|
minPoolSize?: number;
|
|
4597
|
+
/** The maximum number of connections that may be in the process of being established concurrently by the connection pool. */
|
|
4598
|
+
maxConnecting?: number;
|
|
4184
4599
|
/** The maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed. */
|
|
4185
4600
|
maxIdleTimeMS?: number;
|
|
4186
4601
|
/** The maximum time in milliseconds that a thread can wait for a connection to become available. */
|
|
@@ -4289,6 +4704,7 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
4289
4704
|
proxyPassword?: string;
|
|
4290
4705
|
/* Excluded from this release type: srvPoller */
|
|
4291
4706
|
/* Excluded from this release type: connectionType */
|
|
4707
|
+
/* Excluded from this release type: __index */
|
|
4292
4708
|
}
|
|
4293
4709
|
|
|
4294
4710
|
/* Excluded from this release type: MongoClientPrivate */
|
|
@@ -4444,6 +4860,7 @@ export declare const MongoErrorLabel: Readonly<{
|
|
|
4444
4860
|
readonly TransientTransactionError: "TransientTransactionError";
|
|
4445
4861
|
readonly UnknownTransactionCommitResult: "UnknownTransactionCommitResult";
|
|
4446
4862
|
readonly ResumableChangeStreamError: "ResumableChangeStreamError";
|
|
4863
|
+
readonly HandshakeError: "HandshakeError";
|
|
4447
4864
|
}>;
|
|
4448
4865
|
|
|
4449
4866
|
/** @public */
|
|
@@ -4578,7 +4995,7 @@ export declare class MongoNotConnectedError extends MongoAPIError {
|
|
|
4578
4995
|
* Mongo Client Options
|
|
4579
4996
|
* @public
|
|
4580
4997
|
*/
|
|
4581
|
-
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' | 'srvMaxHosts' | 'srvServiceName' | 'tlsAllowInvalidCertificates' | 'tlsAllowInvalidHostnames' | 'tlsInsecure' | 'waitQueueTimeoutMS' | 'zlibCompressionLevel'>>, SupportedNodeConnectionOptions {
|
|
4998
|
+
export declare interface MongoOptions extends Required<Pick<MongoClientOptions, 'autoEncryption' | 'connectTimeoutMS' | 'directConnection' | 'driverInfo' | 'forceServerObjectId' | 'minHeartbeatFrequencyMS' | 'heartbeatFrequencyMS' | 'keepAlive' | 'keepAliveInitialDelay' | 'localThresholdMS' | 'logger' | 'maxConnecting' | 'maxIdleTimeMS' | 'maxPoolSize' | 'minPoolSize' | 'monitorCommands' | 'noDelay' | 'pkFactory' | 'promiseLibrary' | 'raw' | 'replicaSet' | 'retryReads' | 'retryWrites' | 'serverSelectionTimeoutMS' | 'socketTimeoutMS' | 'srvMaxHosts' | 'srvServiceName' | 'tlsAllowInvalidCertificates' | 'tlsAllowInvalidHostnames' | 'tlsInsecure' | 'waitQueueTimeoutMS' | 'zlibCompressionLevel'>>, SupportedNodeConnectionOptions {
|
|
4582
4999
|
hosts: HostAddress[];
|
|
4583
5000
|
srvHost?: string;
|
|
4584
5001
|
credentials?: MongoCredentials;
|
|
@@ -4617,10 +5034,7 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
|
|
|
4617
5034
|
*
|
|
4618
5035
|
*/
|
|
4619
5036
|
tls: boolean;
|
|
4620
|
-
|
|
4621
|
-
* Turn these options into a reusable connection URI
|
|
4622
|
-
*/
|
|
4623
|
-
toURI(): string;
|
|
5037
|
+
/* Excluded from this release type: __index */
|
|
4624
5038
|
}
|
|
4625
5039
|
|
|
4626
5040
|
/**
|
|
@@ -4796,7 +5210,7 @@ export declare interface MonitorOptions extends Omit<ConnectionOptions, 'id' | '
|
|
|
4796
5210
|
*/
|
|
4797
5211
|
export declare type NestedPaths<Type> = Type extends string | number | boolean | Date | RegExp | Buffer | Uint8Array | ((...args: any[]) => any) | {
|
|
4798
5212
|
_bsontype: string;
|
|
4799
|
-
} ? [] : Type extends ReadonlyArray<infer ArrayType> ? [number, ...NestedPaths<ArrayType>] : Type extends Map<string, any> ? [string] : Type extends object ? {
|
|
5213
|
+
} ? [] : Type extends ReadonlyArray<infer ArrayType> ? [] | [number, ...NestedPaths<ArrayType>] : Type extends Map<string, any> ? [string] : Type extends object ? {
|
|
4800
5214
|
[Key in Extract<keyof Type, string>]: Type[Key] extends Type ? [Key] : Type extends Type[Key] ? [Key] : Type[Key] extends ReadonlyArray<infer ArrayType> ? Type extends ArrayType ? [Key] : ArrayType extends Type ? [Key] : [
|
|
4801
5215
|
Key,
|
|
4802
5216
|
...NestedPaths<Type[Key]>
|
|
@@ -4852,10 +5266,9 @@ export declare interface OperationOptions extends BSONSerializeOptions {
|
|
|
4852
5266
|
/* Excluded from this release type: OperationParent */
|
|
4853
5267
|
|
|
4854
5268
|
/**
|
|
4855
|
-
* Represents a specific point in time on a server. Can be retrieved by using
|
|
5269
|
+
* Represents a specific point in time on a server. Can be retrieved by using `db.command()`
|
|
4856
5270
|
* @public
|
|
4857
|
-
* @
|
|
4858
|
-
* See {@link https://docs.mongodb.com/manual/reference/method/db.runCommand/#response| Run Command Response}
|
|
5271
|
+
* @see https://docs.mongodb.com/manual/reference/method/db.runCommand/#response
|
|
4859
5272
|
*/
|
|
4860
5273
|
export declare type OperationTime = Timestamp;
|
|
4861
5274
|
|
|
@@ -5187,7 +5600,10 @@ export declare interface ReplaceOptions extends CommandOperationOptions {
|
|
|
5187
5600
|
|
|
5188
5601
|
/* Excluded from this release type: Response */
|
|
5189
5602
|
|
|
5190
|
-
/**
|
|
5603
|
+
/**
|
|
5604
|
+
* @public
|
|
5605
|
+
* @deprecated Please use the ChangeStreamCursorOptions type instead.
|
|
5606
|
+
*/
|
|
5191
5607
|
export declare interface ResumeOptions {
|
|
5192
5608
|
startAtOperationTime?: Timestamp;
|
|
5193
5609
|
batchSize?: number;
|
|
@@ -5196,10 +5612,12 @@ export declare interface ResumeOptions {
|
|
|
5196
5612
|
readPreference?: ReadPreference;
|
|
5197
5613
|
resumeAfter?: ResumeToken;
|
|
5198
5614
|
startAfter?: ResumeToken;
|
|
5615
|
+
fullDocument?: string;
|
|
5199
5616
|
}
|
|
5200
5617
|
|
|
5201
5618
|
/**
|
|
5202
|
-
* Represents the logical starting point for a new or resuming
|
|
5619
|
+
* Represents the logical starting point for a new ChangeStream or resuming a ChangeStream on the server.
|
|
5620
|
+
* @see https://www.mongodb.com/docs/manual/changeStreams/#std-label-change-stream-resume
|
|
5203
5621
|
* @public
|
|
5204
5622
|
*/
|
|
5205
5623
|
export declare type ResumeToken = unknown;
|
|
@@ -5708,6 +6126,7 @@ export declare interface TopologyOptions extends BSONSerializeOptions, ServerOpt
|
|
|
5708
6126
|
metadata: ClientMetadata;
|
|
5709
6127
|
/** MongoDB server API version */
|
|
5710
6128
|
serverApi?: ServerApi;
|
|
6129
|
+
/* Excluded from this release type: __index */
|
|
5711
6130
|
}
|
|
5712
6131
|
|
|
5713
6132
|
/* Excluded from this release type: TopologyPrivate */
|
|
@@ -5770,6 +6189,7 @@ export declare interface TransactionOptions extends CommandOperationOptions {
|
|
|
5770
6189
|
writeConcern?: WriteConcern;
|
|
5771
6190
|
/** A default read preference for commands in this transaction */
|
|
5772
6191
|
readPreference?: ReadPreference;
|
|
6192
|
+
/** Specifies the maximum amount of time to allow a commit action on a transaction to run in milliseconds */
|
|
5773
6193
|
maxCommitTimeMS?: number;
|
|
5774
6194
|
}
|
|
5775
6195
|
|
|
@@ -5831,11 +6251,24 @@ export declare interface UpdateDescription<TSchema extends Document = Document>
|
|
|
5831
6251
|
* A document containing key:value pairs of names of the fields that were
|
|
5832
6252
|
* changed, and the new value for those fields.
|
|
5833
6253
|
*/
|
|
5834
|
-
updatedFields
|
|
6254
|
+
updatedFields?: Partial<TSchema>;
|
|
5835
6255
|
/**
|
|
5836
6256
|
* An array of field names that were removed from the document.
|
|
5837
6257
|
*/
|
|
5838
|
-
removedFields
|
|
6258
|
+
removedFields?: string[];
|
|
6259
|
+
/**
|
|
6260
|
+
* An array of documents which record array truncations performed with pipeline-based updates using one or more of the following stages:
|
|
6261
|
+
* - $addFields
|
|
6262
|
+
* - $set
|
|
6263
|
+
* - $replaceRoot
|
|
6264
|
+
* - $replaceWith
|
|
6265
|
+
*/
|
|
6266
|
+
truncatedArrays?: Array<{
|
|
6267
|
+
/** The name of the truncated field. */
|
|
6268
|
+
field: string;
|
|
6269
|
+
/** The number of elements in the truncated array. */
|
|
6270
|
+
newSize: number;
|
|
6271
|
+
}>;
|
|
5839
6272
|
}
|
|
5840
6273
|
|
|
5841
6274
|
/** @public */
|