Skip to content

Commit 4fc0bd5

Browse files
committed
Add 4.0 reference documantation
* Update What's New in 3.8 * Add change stream examples for MongoDatabase and MongoClient
1 parent 26c66e9 commit 4fc0bd5

File tree

3 files changed

+64
-5
lines changed

3 files changed

+64
-5
lines changed

docs/reference/content/driver-async/tutorials/change-streams.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title = "Change Streams"
88
pre = "<i class='fa'></i>"
99
+++
1010

11-
## Change Streams - Draft
11+
## Change Streams
1212

1313
MongoDB 3.6 introduces a new [`$changeStream`](http://dochub.mongodb.org/core/changestreams) aggregation pipeline
1414
operator.
@@ -74,14 +74,40 @@ For additional information on connecting to MongoDB, see [Connect to MongoDB]({{
7474

7575
## Watch the collection
7676

77-
To create a change stream use the the [`MongoCollection.watch()`]({{<apiref "com/mongodb/client/MongoCollection.html#watch">}}) method.
77+
To create a change stream use one the [`MongoCollection.watch()`]({{<apiref "com/mongodb/async/client/MongoCollection.html#watch">}})
78+
methods.
7879

7980
In the following example, the change stream prints out all changes it observes.
8081

8182
```java
8283
collection.watch().forEach(printBlock, callbackWhenFinished);
8384
```
8485

86+
## Watch the database
87+
88+
New in the 3.8 driver and MongoDB 4.0, applications can open a single change stream to watch all non-system collections of a database. To
89+
create such a change stream use one of the [`MongoDatabase.watch()`]({{<apiref "com/mongodb/async/client/MongoDatabase.html#watch">}})
90+
methods.
91+
92+
In the following example, the change stream prints out all the changes it observes on the given database.
93+
94+
```java
95+
database.watch().forEach(printBlock, callbackWhenFinished);
96+
```
97+
98+
## Watch all databases
99+
100+
New in the 3.8 driver and MongoDB 4.0, applications can open a single change stream to watch all non-system collections of all databases
101+
in a MongoDB deployment. To create such a change stream use one of the
102+
[`MongoClient.watch()`]({{<apiref "com/mongodb/async/client/MongoClient.html#watch">}}) methods.
103+
104+
In the following example, the change stream prints out all the changes it observes on the deployement to which the `MongoClient` is
105+
connected
106+
107+
```java
108+
mongoClient.watch().forEach(printBlock, callbackWhenFinished);
109+
```
110+
85111
## Filtering content
86112

87113
The `watch` method can also be passed a list of [aggregation stages]({{< docsref "meta/aggregation-quick-reference" >}}), that can modify

docs/reference/content/driver/tutorials/change-streams.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title = "Change Streams"
88
pre = "<i class='fa'></i>"
99
+++
1010

11-
## Change Streams - Draft
11+
## Change Streams
1212

1313
MongoDB 3.6 introduces a new [`$changeStream`](http://dochub.mongodb.org/core/changestreams) aggregation pipeline
1414
operator.
@@ -63,14 +63,38 @@ For additional information on connecting to MongoDB, see [Connect to MongoDB]({{
6363

6464
## Watch the collection
6565

66-
To create a change stream use the the [`MongoCollection.watch()`]({{<apiref "com/mongodb/client/MongoCollection.html#watch">}}) method.
66+
To create a change stream use one of the [`MongoCollection.watch()`]({{<apiref "com/mongodb/client/MongoCollection.html#watch">}}) methods.
6767

6868
In the following example, the change stream prints out all changes it observes.
6969

7070
```java
7171
collection.watch().forEach(printBlock);
7272
```
7373

74+
## Watch the database
75+
76+
New in the 3.8 driver and MongoDB 4.0, applications can open a single change stream to watch all non-system collections of a database. To
77+
create such a change stream use one of the [`MongoDatabase.watch()`]({{<apiref "com/mongodb/client/MongoDatabase.html#watch">}}) methods.
78+
79+
In the following example, the change stream prints out all the changes it observes on the given database.
80+
81+
```java
82+
database.watch().forEach(printBlock);
83+
```
84+
85+
## Watch all databases
86+
87+
New in the 3.8 driver and MongoDB 4.0, applications can open a single change stream to watch all non-system collections of all databases
88+
in a MongoDB deployment. To create such a change stream use one of the
89+
[`MongoClient.watch()`]({{<apiref "com/mongodb/client/MongoClient.html#watch">}}) methods.
90+
91+
In the following example, the change stream prints out all the changes it observes on the deployement to which the `MongoClient` is
92+
connected
93+
94+
```java
95+
mongoClient.watch().forEach(printBlock);
96+
```
97+
7498
## Filtering content
7599

76100
The `watch` method can also be passed a list of [aggregation stages]({{< docsref "meta/aggregation-quick-reference" >}}), that can modify

docs/reference/content/whats-new.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ Key new features of the 3.8 Java driver release:
1313

1414
### Transactions
1515

16-
The Java driver now provides support for executing CRUD operations within a transaction (requires MongoDB 4.0).
16+
The Java driver now provides support for executing CRUD operations within a transaction (requires MongoDB 4.0). See the
17+
[Transactions and MongoDB Drivers](https://docs.mongodb.com/master/core/transactions/#transactions-and-mongodb-drivers) section
18+
of the documentation and select the `Java (Sync)` tab.
19+
20+
### Change Stream enhancements
21+
22+
The Java driver now provides support for opening a change stream against an entire database, via new
23+
[`MongoDatabase.watch`]({{<apiref "com/mongodb/client/MongoDatabase.html">}}) methods, or an
24+
entire deployment, via new [`MongoClient.watch`]({{<apiref "com/mongodb/client/MongoClient.html">}}) methods. See
25+
[Change Streams]({{<ref "driver/tutorials/change-streams.md">}}) for further details.
1726

1827
### SCRAM-256 Authentication Mechanism
1928

0 commit comments

Comments
 (0)