File tree Expand file tree Collapse file tree 6 files changed +24
-7
lines changed Expand file tree Collapse file tree 6 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ Additional Information
61
61
API Documentation
62
62
~~~~~~~~~~~~~~~~~
63
63
64
- For additional information on the classes and methods used to run database commands, see the following API documentation:
64
+ For additional information on the method used to run database commands, see the following API documentation:
65
65
66
66
- `runCommand() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoDatabase.html#runCommand(org.bson.conversions.Bson)>`__
67
67
Original file line number Diff line number Diff line change @@ -11,9 +11,10 @@ Count Documents
11
11
:depth: 2
12
12
:class: singlecol
13
13
14
- In this guide, you can learn how to count documents in your MongoDB
15
- database collection. There are two instance methods in the ``MongoCollection``
16
- class that you can call to count the number of documents in a collection:
14
+ In this guide, you can learn how to count the number of documents in your
15
+ MongoDB database collections. There are two instance methods in the
16
+ ``MongoCollection`` class that you can call to count the number of documents in
17
+ a collection:
17
18
18
19
- ``countDocuments()`` returns the number of documents in the collection
19
20
that match a specified query. If you specify an empty query filter,
@@ -83,13 +84,13 @@ Both methods return the number of matching documents as a ``long`` primitive.
83
84
Count Documents Example: Full File
84
85
----------------------------------
85
86
87
+ .. include:: /includes/crud/example-intro.rst
88
+
86
89
The following example estimates the number of documents in the
87
90
``movies`` collection in the ``sample_mflix`` database, and then returns
88
91
an accurate count of the number of documents in the ``movies``
89
92
collection with ``Canada`` in the ``countries`` field.
90
93
91
- .. include:: /includes/connect-guide-note.rst
92
-
93
94
.. literalinclude:: /includes/crud/CountDocuments.java
94
95
:language: java
95
96
Original file line number Diff line number Diff line change
1
+ // Runs a database command by using the Java driver
2
+
1
3
package org .example ;
2
4
3
5
import org .bson .BsonDocument ;
Original file line number Diff line number Diff line change 1
- // Runs count operations on a collection by using the Java driver
1
+ /**
2
+ * This file demonstrates how to open a change stream by using the Java driver.
3
+ * It connects to a MongoDB deployment, accesses the "sample_mflix" database, and listens
4
+ * to change events in the "movies" collection. The code uses a change stream with a pipeline
5
+ * to only filter for "insert" and "update" events.
6
+ */
2
7
3
8
package usage .examples ;
4
9
Original file line number Diff line number Diff line change
1
+ /**
2
+ * This file demonstrates how to open a change stream by using the Java driver.
3
+ * It connects to a MongoDB deployment, accesses the "sample_mflix" database, and listens
4
+ * to change events in the "movies" collection. The code uses a change stream with a pipeline
5
+ * to only filter for "insert" and "update" events.
6
+ */
7
+
1
8
package org .example ;
2
9
3
10
import java .util .Arrays ;
Original file line number Diff line number Diff line change
1
+ // Performs CRUD operations to generate change events when run with the Watch application
2
+
1
3
package org .example ;
2
4
3
5
import org .bson .Document ;
You can’t perform that action at this time.
0 commit comments