You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.
1420
1420
*
1421
-
* @since 3.0.0
1421
+
* @remarks
1422
+
* watch() accepts two generic arguments for distinct usecases:
1423
+
* - The first is to override the schema that may be defined for this specific collection
1424
+
* - 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
1425
+
* @example
1426
+
* By just providing the first argument I can type the change to be `ChangeStreamDocument<{ _id: number }>`
* // No need to narrow in code because the generics did that for us!
1447
+
* expectType<Schema>(change.fullDocument);
1448
+
* });
1449
+
* ```
1450
+
*
1422
1451
* @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.
1423
1452
* @param options - Optional settings for the command
1453
+
* @typeParam TLocal - Type of the data being detected by the change stream
1454
+
* @typeParam TChange - Type of the whole change stream document emitted
* replacements, deletions, and invalidations) in this database. Will ignore all
720
720
* changes to system collections.
721
721
*
722
+
* @remarks
723
+
* watch() accepts two generic arguments for distinct usecases:
724
+
* - The first is to provide the schema that may be defined for all the collections within this database
725
+
* - 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
726
+
*
722
727
* @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.
723
728
* @param options - Optional settings for the command
729
+
* @typeParam TSchema - Type of the data being detected by the change stream
730
+
* @typeParam TChange - Type of the whole change stream document emitted
@@ -590,20 +590,27 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> {
590
590
* replacements, deletions, and invalidations) in this cluster. Will ignore all
591
591
* changes to system collections, as well as the local, admin, and config databases.
592
592
*
593
+
* @remarks
594
+
* watch() accepts two generic arguments for distinct usecases:
595
+
* - The first is to provide the schema that may be defined for all the data within the current cluster
596
+
* - 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
597
+
*
593
598
* @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.
594
599
* @param options - Optional settings for the command
600
+
* @typeParam TSchema - Type of the data being detected by the change stream
601
+
* @typeParam TChange - Type of the whole change stream document emitted
0 commit comments