Skip to content

Commit 32179bd

Browse files
committed
run command
1 parent 48b536b commit 32179bd

File tree

5 files changed

+45
-20
lines changed

5 files changed

+45
-20
lines changed

source/command.txt

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Run a Command
33
=============
44

5-
You can run all raw database operations using the
5+
.. contents:: On this page
6+
:local:
7+
:backlinks: none
8+
:depth: 2
9+
:class: singlecol
10+
11+
In this guide, you can learn how to run raw database operations using the
612
``MongoDatabase.runCommand()`` method. A raw database operation is a
713
command you can execute directly on the {+mdb-server+} CLI. These
814
commands include administrative and diagnostic tasks, such as fetching
@@ -28,18 +34,17 @@ By default, ``runCommand`` returns an object of type
2834
can specify a return type for ``runCommand()`` as an optional second
2935
parameter.
3036

31-
Example
32-
-------
37+
Run Command Example: Full File
38+
------------------------------
3339

3440
In the following sample code, we send the ``dbStats`` command to request
3541
statistics from a specific MongoDB database.
3642

3743
.. include:: /includes/connect-guide-note.rst
3844

39-
.. literalinclude:: /includes/usage-examples/code-snippets/Command.java
45+
.. literalinclude:: /includes/Command.java
4046
:language: java
4147

42-
4348
When you run the preceding command, you should see output similar to the
4449
following:
4550

@@ -50,9 +55,18 @@ following:
5055

5156
.. include:: /includes/legacy-redirect.rst
5257

53-
For additional information on the classes and methods mentioned on this
54-
page, see the following resources:
58+
Additional Information
59+
----------------------
60+
61+
API Documentation
62+
~~~~~~~~~~~~~~~~~
63+
64+
For additional information on the classes and methods used to run database commands, see the following API documentation:
65+
66+
- `runCommand() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoDatabase.html#runCommand(org.bson.conversions.Bson)>`__
67+
68+
Server Manual Entries
69+
~~~~~~~~~~~~~~~~~~~~~
5570

56-
- `runCommand() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoDatabase.html#runCommand(org.bson.conversions.Bson)>`__ API Documentation
57-
- :manual:`Database Commands </reference/command/>` Server Manual Entry
58-
- :manual:`dbStats </reference/command/dbStats/>` Server Manual Entry
71+
- :manual:`Database Commands </reference/command/>`
72+
- :manual:`dbStats </reference/command/dbStats/>`

source/crud/read-operations.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Read Operations
1616
Skip Returned Results </crud/read-operations/skip>
1717
Limit Returned Results </crud/read-operations/limit>
1818
Specify Fields to Return </crud/read-operations/project>
19+
Count Documents </crud/read-operations/count>
1920
Geospatial Data </crud/read-operations/geo>
2021
Search Text </crud/read-operations/text>
2122

@@ -25,5 +26,6 @@ Read Operations
2526
- :doc:`/crud/read-operations/skip`
2627
- :doc:`/crud/read-operations/limit`
2728
- :doc:`/crud/read-operations/project`
29+
- :doc:`/crud/read-operations/count`
2830
- :doc:`/crud/read-operations/geo`
2931
- :doc:`/crud/read-operations/text`

source/crud/read-operations/count.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Count Documents
88
.. contents:: On this page
99
:local:
1010
:backlinks: none
11-
:depth: 1
11+
:depth: 2
1212
:class: singlecol
1313

1414
In this guide, you can learn how to count documents in your MongoDB
@@ -80,8 +80,8 @@ specify the behavior of the call:
8080

8181
Both methods return the number of matching documents as a ``long`` primitive.
8282

83-
Example
84-
-------
83+
Count Documents Example: Full File
84+
----------------------------------
8585

8686
The following example estimates the number of documents in the
8787
``movies`` collection in the ``sample_mflix`` database, and then returns
@@ -104,10 +104,21 @@ like this (exact numbers can vary depending on your data):
104104

105105
.. include:: /includes/legacy-redirect.rst
106106

107-
For additional information on the classes and methods mentioned on this
108-
page, see the following API Documentation:
107+
Additional Information
108+
----------------------
109+
110+
API Documentation
111+
~~~~~~~~~~~~~~~~~
112+
113+
For additional information on the classes and methods used to count documents, see the following API documentation:
109114

110115
- `countDocuments() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#countDocuments()>`__
111116
- `estimatedDocumentCount() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#estimatedDocumentCount()>`__
112117
- `CountOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/CountOptions.html>`__
113118
- `EstimatedDocumentCountOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/EstimatedDocumentCountOptions.html>`__
119+
120+
Server Manual Entries
121+
~~~~~~~~~~~~~~~~~~~~~
122+
123+
- :manual:`db.collection.countDocuments() </reference/method/db.collection.countDocuments/>`
124+
- :manual:`db.collection.estimatedDocumentCount() </reference/method/db.collection.estimatedDocumentCount/>`

source/includes/crud/Command.java renamed to source/includes/RunCommand.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// Runs a database command by using the Java driver
2-
3-
package usage.examples;
1+
package org.example;
42

53
import org.bson.BsonDocument;
64
import org.bson.BsonInt64;

source/logging-monitoring/change-streams.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,11 @@ API documentation.
465465
Additional Information
466466
----------------------
467467

468-
To learn more about the methods and classes used to manage change streams, see the following API documentation:
469-
470468
API Documentation
471469
~~~~~~~~~~~~~~~~~
472470

471+
To learn more about the methods and classes used to manage change streams, see the following API documentation:
472+
473473
- `MongoCollection.watch() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#watch()>`__
474474
- `MongoDatabase.watch() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoDatabase.html#watch()>`__
475475
- `MongoClient.watch() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoClient.html#watch()>`__

0 commit comments

Comments
 (0)