Skip to content

Commit 74d6478

Browse files
DOCSP-39702 Standardize change streams page (#69)
1 parent 981dfbb commit 74d6478

File tree

4 files changed

+281
-127
lines changed

4 files changed

+281
-127
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// start-open-change-stream
2+
// Opens a change stream and prints the changes as they're received
3+
ChangeStreamPublisher<Document> changeStreamPublisher = restaurants.watch();
4+
Flux.from(changeStreamPublisher)
5+
.doOnNext(change -> System.out.println("Received change: " + change))
6+
.blockLast();
7+
// end-open-change-stream
8+
9+
// start-change-stream-pipeline
10+
// Creates a change stream pipeline
11+
List<Bson> pipeline = Arrays.asList(
12+
Aggregates.match(Filters.eq("operationType", "update"))
13+
);
14+
15+
// Opens a change stream and prints the changes as they're received
16+
ChangeStreamPublisher<Document> changeStreamPublisher = restaurants.watch(pipeline);
17+
Flux.from(changeStreamPublisher)
18+
.doOnNext(change -> System.out.println("Received change: " + change))
19+
.blockLast();
20+
// end-change-stream-pipeline
21+
22+
// start-change-stream-post-image
23+
// Creates a change stream pipeline
24+
List<Bson> pipeline = Arrays.asList(
25+
Aggregates.match(Filters.eq("operationType", "update"))
26+
);
27+
28+
// Opens a change stream and prints the changes as they're received including the full
29+
// document after the update
30+
ChangeStreamPublisher<Document> changeStreamPublisher = restaurants.watch(pipeline)
31+
.fullDocument(FullDocument.UPDATE_LOOKUP);
32+
33+
Flux.from(changeStreamPublisher)
34+
.doOnNext(change -> System.out.println("Received change: " + change))
35+
.blockLast();
36+
// end-change-stream-post-image

source/read-data-from-mongo.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Read Data From MongoDB
3131
/read/read-preference
3232
/read/text-search
3333
/read/geo
34-
/read/change-stream
34+
/read/change-streams
3535

3636
Overview
3737
--------
@@ -181,4 +181,4 @@ subsequent change events in that collection:
181181
:language: java
182182
:copyable:
183183

184-
To learn more about the ``watch()`` method, see the :ref:`Monitor Data Changes <java-rs-monitor-changes>` guide.
184+
To learn more about the ``watch()`` method, see the :ref:`Monitor Data Changes <java-rs-change-streams>` guide.

source/read/change-stream.txt

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)