Skip to content

Commit 8502642

Browse files
authored
DOCSP-24399 cherry-pick/merge (#1782)
1 parent a4ee267 commit 8502642

24 files changed

+103
-67
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
.. tip::
3+
4+
In :program:`mongosh`, this command can also be run through the |method|.
5+
6+
Helper methods are convenient for :program:`mongosh` users, but they may not
7+
return the same level of information as database commands. In cases where
8+
the convenience is not needed or the additional return fields are required,
9+
use the database command.
10+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. important:: ``mongosh`` Method
2+
3+
This page documents a :binary:`~bin.mongosh` method. This is *not*
4+
the documentation for database commands or language-specific drivers,
5+
such as Node.js. To use the database command, see the |dbcommand|.
6+
7+
For MongoDB API drivers, refer to the language-specific
8+
:driver:`MongoDB driver documentation </>`.
9+
10+
For the legacy ``mongo`` shell documentation, refer to the
11+
documentation for the corresponding MongoDB Server release:
12+
13+
- :v4.4:`mongo shell v4.4 </mongo>`
14+
- :v4.2:`mongo shell v4.2 </mongo>`

source/reference/command/aggregate.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Definition
2020
to process data from a collection or other source with a sequence of
2121
stage-based manipulations.
2222

23+
.. |method| replace:: :method:`db.aggregate()` and
24+
:method:`db.collection.aggregate()` helper methods
25+
.. include:: /includes/fact-dbcommand-tip
26+
2327
Syntax
2428
------
2529

source/reference/command/createIndexes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Definition
1717

1818
Builds one or more indexes on a collection.
1919

20+
.. |method| replace:: :method:`db.collection.createIndex()` and
21+
:method:`db.collection.createIndexes()` helper methods.
22+
.. include:: /includes/fact-dbcommand-tip
23+
2024
The :dbcommand:`createIndexes` command takes the following form:
2125

2226
.. code-block:: javascript

source/reference/command/distinct.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Definition
2020
an array of the distinct values. The return document also contains
2121
an embedded document with query statistics and the query plan.
2222

23+
.. |method| replace:: :method:`db.collection.distinct()` helper method.
24+
.. include:: /includes/fact-dbcommand-tip
25+
2326
The command takes the following form
2427

2528
.. code-block:: javascript

source/reference/command/dropIndexes.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ dropIndexes
1616
(except the index on the ``_id`` field) from the specified
1717
collection.
1818

19+
.. |method| replace:: :method:`db.collection.dropIndex()` and
20+
:method:`db.collection.dropIndexes()` helper methods.
21+
.. include:: /includes/fact-dbcommand-tip
22+
1923
The command has the following form:
20-
24+
2125
.. code-block:: javascript
2226

2327
{ dropIndexes: <string>, index: <string|document|arrayofstrings>, writeConcern: <document>, comment: <any> }

source/reference/command/explain.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ Definition
2121
:dbcommand:`findAndModify`, :dbcommand:`delete`,
2222
:dbcommand:`mapReduce`, and :dbcommand:`update`.
2323

24-
Although MongoDB provides the :dbcommand:`explain` command, the
25-
preferred method for running :dbcommand:`explain` is to use the
26-
:method:`db.collection.explain()` and :method:`cursor.explain()` helpers.
24+
.. |method| replace:: :method:`db.collection.explain()` and
25+
:method:`cursor.explain()` helper methods
26+
27+
.. include:: /includes/fact-dbcommand-tip
2728

2829
The :dbcommand:`explain` command has the following syntax:
2930

source/reference/command/find.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ Definition
2020
Executes a query and returns the first batch of results and the
2121
cursor id, from which the client can construct a cursor.
2222

23-
.. tip::
24-
25-
Rather than run the :dbcommand:`find` command directly, you can
26-
use the :method:`db.collection.find()` helper provided in
27-
:binary:`~bin.mongosh` or the equivalent helper in the
28-
drivers.
23+
.. |method| replace:: :method:`db.collection.find()` or
24+
:method:`db.collection.findOne()` helper methods
25+
.. include:: /includes/fact-dbcommand-tip
2926

3027
Syntax
3128
------

source/reference/command/findAndModify.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Definition
2424
modifications made on the update. To return the document with the
2525
modifications made on the update, use the ``new`` option.
2626

27+
.. |method| replace:: :method:`db.collection.findAndModify()` helper method
28+
.. include:: /includes/fact-dbcommand-tip
29+
2730
.. versionchanged:: 5.0
2831

2932
The command has the following syntax:

source/reference/command/insert.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Definition
1919
returns a document containing the status of all inserts. The insert
2020
methods provided by the MongoDB drivers use this command internally.
2121

22+
.. |method| replace:: :method:`db.collection.insertOne()` and
23+
:method:`db.collection.insertMany()` helper methods
24+
.. include:: /includes/fact-dbcommand-tip
25+
2226
The command has the following syntax:
2327

2428
.. code-block:: javascript

0 commit comments

Comments
 (0)