Skip to content

Commit 99e8ec5

Browse files
committed
Corrected the sample location and repo path
1 parent dabfa4a commit 99e8ec5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

articles/cosmos-db/mongodb-change-streams.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,21 @@ while (enumerator.MoveNext()){
7777

7878
enumerator.Dispose();
7979
```
80-
80+
```java
81+
Bson match=Aggregates.match(Filters.in("operationType",
82+
asList("update", "replace", "insert")));
83+
Bson project=Aggregates.project(fields(include("_id","ns","documentKey","fullDocument")));
84+
85+
List<Bson> pipeline =Arrays.asList(match,project);
86+
MongoChangeStreamCursor<ChangeStreamDocument<org.bson.Document>> cursor =
87+
collection.watch(pipeline).fullDocument(FullDocument.UPDATE_LOOKUP).cursor();
88+
89+
while (cursor.hasNext()) {
90+
System.out.println(cursor.next());
91+
}
92+
cursor.close();
93+
```
94+
Refer [here](https://github.com/Azure-Samples/azure-cosmos-db-mongodb-java-changestream), for full sample in Java.
8195
## Changes within a single shard
8296

8397
The following example shows how to get changes to the items within a single shard. This example gets the changes of items that have shard key equal to "a" and the shard key value equal to "1". It is possible to have different clients reading changes from different shards in parallel.
@@ -112,7 +126,7 @@ var cursor = db.coll.watch(
112126
}
113127
cursor.close();
114128
```
115-
Refer [here](https://github.com/Azure-Samples/mongo-changestream), for full sample in Java.
129+
Refer [here](https://github.com/Azure-Samples/azure-cosmos-db-mongodb-java-changestream), for full sample in Java.
116130
## Current limitations
117131

118132
The following limitations are applicable when using change streams:

0 commit comments

Comments
 (0)