-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOCSP-39732 Run a command standardization (#77)
- Loading branch information
1 parent
32dcdcd
commit 50f67a4
Showing
4 changed files
with
76 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Document command = new Document("ping", 1); | ||
|
||
Publisher<Document> commandPublisher = database.runCommand(command); | ||
Document result = Mono.from(commandPublisher).block(); | ||
System.out.println(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.. _java-rs-run-command: | ||
|
||
====================== | ||
Run a Database Command | ||
====================== | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 2 | ||
:class: singlecol | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: reference | ||
|
||
.. meta:: | ||
:keywords: database operation, code example | ||
|
||
Overview | ||
-------- | ||
|
||
In this guide, you can learn how to run a database command with the | ||
{+driver-short+}. You can use database commands to perform a variety of administrative and | ||
diagnostic tasks, such as fetching server statistics, initializing a replica | ||
set, or running an aggregation pipeline. | ||
|
||
.. tip:: Prefer Driver Methods Over Database Commands | ||
|
||
The driver provides methods for many database commands. We recommend | ||
using driver methods instead of executing database commands when possible. | ||
|
||
To perform administrative tasks, use the :mdb-shell:`MongoDB Shell </>` instead of the | ||
{+driver-short+}. Calling the MongoDB Shell :manual:`db.runCommand() | ||
</reference/method/db.runCommand/>` method is the preferred method to issue | ||
database commands, as it provides a consistent interface between the shell | ||
and drivers. | ||
|
||
.. include:: includes/reactor-note.rst | ||
|
||
Run a Command | ||
------------- | ||
|
||
To run a database command, specify the command in a document, and pass the | ||
document to the ``runCommand()`` method. The following code calls the | ||
``runCommand()`` method on a database to run the ``ping`` command, which is a | ||
no-op command used to test if a server is responsive. | ||
|
||
.. io-code-block:: | ||
|
||
.. input:: /includes/write/run-command.java | ||
:language: java | ||
:emphasize-lines: 1, 3 | ||
|
||
.. output:: | ||
:visible: false | ||
|
||
Document{{ok=1}} | ||
|
||
Additional Information | ||
---------------------- | ||
|
||
To see a full list of database commands and their available parameters, see :manual:`Database | ||
Commands </reference/command>` in the {+mdb-server+} manual. | ||
|
||
API Documentation | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
To learn more about the ``runCommand()`` method, see the | ||
`runCommand() API documentation <{+api+}/mongodb-driver-reactivestreams/com/mongodb/reactivestreams/client/MongoDatabase.html#runCommand(org.bson.conversions.Bson)>`__. |