Skip to content

Commit 0c285a5

Browse files
authored
Merge pull request #18 from rustagir/DOCSP-37862-command
DOCSP-37862: command tutorial
2 parents f7e8ddc + 0e3fbf4 commit 0c285a5

File tree

11 files changed

+86
-17
lines changed

11 files changed

+86
-17
lines changed

source/get-started/pojo-qs.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,4 @@ The following example deletes all ``Person`` instances that have an
340340
Additional Information
341341
~~~~~~~~~~~~~~~~~~~~~~
342342

343-
..
344-
TODO update link
345-
To find additional tutorials, see the :ref:`Tutorials <>` section.
343+
To find additional tutorials, see the :ref:`javars-tutorials` section.

source/get-started/primer.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ This guide provides background about the {+driver-short+} and its
1414
asynchronous API before showing you how to use the driver and MongoDB in
1515
the :ref:`Quick Start guide <javars-quickstart>`.
1616

17-
.. TODO fix ref above when QS is made
18-
1917
.. note::
2018

2119
See the :ref:`Installation guide <javars-install>`

source/get-started/quickstart.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,12 @@ The following example creates an ascending index on the ``i`` field:
536536
collection.createIndex(new Document("i", 1))
537537
.subscribe(new PrintSubscriber<String>("Create Index Result: %s"));
538538

539-
.. TODO For a list of other index types, see the :ref:`Indexes <>` guide.
539+
To view a list of other index types, see the :ref:`javars-indexes` guide.
540540

541541
Additional Information
542542
----------------------
543543

544544
For additional tutorials that demonstrate how to use MongoDB with POJOs,
545545
see the :ref:`Quick Start (POJO Examples) guide <javars-pojo-qs>`.
546546

547-
..
548-
TODO update link
549-
To find additional tutorials, see the :ref:`Tutorials <>` section.
547+
To find additional tutorials, see the :ref:`javars-tutorials` section.

source/tutorials.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ Tutorials
1717
/tutorials/text-search/
1818
/tutorials/geo/
1919
/tutorials/gridfs/
20+
/tutorials/command/
2021

source/tutorials/aggregation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ this guide:
4949
Connect to a MongoDB Deployment
5050
-------------------------------
5151

52-
First, connect to a MongoDB deployment and declare and define
52+
First, connect to a MongoDB deployment, then declare and define
5353
``MongoDatabase`` and ``MongoCollection`` instances.
5454

5555
The following code connects to a standalone

source/tutorials/change-stream.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ this guide:
5353
Connect to a MongoDB Deployment
5454
-------------------------------
5555

56-
First, connect to a MongoDB deployment and declare and define
56+
First, connect to a MongoDB deployment, then declare and define
5757
``MongoDatabase`` and ``MongoCollection`` instances.
5858

5959
The following code connects to a standalone

source/tutorials/command.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.. _javars-run-command:
2+
3+
============
4+
Run Commands
5+
============
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
Not all database commands have a specific helper method. However, you can
14+
run any MongoDB command by using the ``MongoDatabase.runCommand()``
15+
method.
16+
17+
To learn more about MongoDB commands, see :manual:`Database Commands </reference/command/>`
18+
in the Server manual.
19+
20+
Prerequisites
21+
-------------
22+
23+
You must set up the following components to run the code examples in
24+
this guide:
25+
26+
- A ``test.restaurants`` collection populated with documents from the
27+
``restaurants.json`` file in the `documentation assets GitHub
28+
<https://raw.githubusercontent.com/mongodb/docs-assets/drivers/restaurants.json>`__.
29+
30+
- The following import statements:
31+
32+
.. code-block:: java
33+
34+
import com.mongodb.reactivestreams.client.MongoClients;
35+
import com.mongodb.reactivestreams.client.MongoClient;
36+
import com.mongodb.reactivestreams.client.MongoDatabase;
37+
import org.bson.Document;
38+
39+
.. important::
40+
41+
This guide uses the ``Subscriber`` implementations, which are
42+
described in the :ref:`Quick Start Primer <javars-primer>`.
43+
44+
Connect to a MongoDB Deployment
45+
-------------------------------
46+
47+
First, connect to a MongoDB deployment, then declare and define
48+
a ``MongoDatabase`` instance.
49+
50+
The following code connects to a standalone
51+
MongoDB deployment running on ``localhost`` on port ``27017``. Then, it
52+
defines the ``database`` variable to refer to the ``test`` database:
53+
54+
.. code-block:: java
55+
56+
MongoClient mongoClient = MongoClients.create();
57+
MongoDatabase database = mongoClient.getDatabase("test");
58+
59+
To learn more about connecting to MongoDB deployments,
60+
see the :ref:`javars-connect` tutorial.
61+
62+
Run the buildInfo Command
63+
-------------------------
64+
65+
To run the ``buildInfo`` command, construct a ``Document`` object that
66+
specifies the command and pass it as a paramter to the ``runCommand()`` method.
67+
68+
The following sample code runs the ``buildInfo`` command and prints
69+
the results:
70+
71+
.. code-block:: java
72+
73+
database.runCommand(new Document("buildInfo", 1)).subscribe(new PrintDocumentSubscriber());

source/tutorials/db-coll.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ properties, such as different :manual:`read concerns
193193
- ``MongoCollection.withReadPreference()``
194194
- ``MongoCollection.withWriteConcern()``
195195

196-
.. TODO To learn more, see the `Read Operations` and `Write Operations` tutorials.
196+
To learn more, see the :ref:`javars-read-operations` and
197+
:ref:`javars-write-ops` tutorials.
197198

198199
CodecRegistry
199200
-------------

source/tutorials/indexes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ code examples in this guide:
5050
Connect to a MongoDB Deployment
5151
-------------------------------
5252

53-
First, connect to a MongoDB deployment and declare and define
53+
First, connect to a MongoDB deployment, then declare and define
5454
``MongoDatabase`` and ``MongoCollection`` instances.
5555

5656
The following code connects to a standalone

source/tutorials/read-ops.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ this guide:
5151
Connect to a MongoDB Deployment
5252
-------------------------------
5353

54-
First, connect to a MongoDB deployment and declare and define
54+
First, connect to a MongoDB deployment, then declare and define
5555
``MongoDatabase`` and ``MongoCollection`` instances.
5656

5757
The following code connects to a standalone
@@ -189,8 +189,8 @@ provides the ``Projections`` class.
189189
In the projection document, you can also specify a projection
190190
expression by using a projection operator.
191191

192-
.. TODO update link To view an example that uses the ``Projections.metaTextScore()`` method, see the
193-
.. :ref:`Text Search <>` tutorial.
192+
To view an example that uses the ``Projections.metaTextScore()`` method, see the
193+
:ref:`javars-text-search` tutorial.
194194

195195
Sorts
196196
~~~~~

0 commit comments

Comments
 (0)