Skip to content

Commit a9fb508

Browse files
authored
DOCSP-24399 collection interlink v4.2 (#1790)
* DOCSP-24399 Merge interlink from v4.4 * DOCSP-24399 Fixes build warnings * DOCSP-24399 Fixes build warnings
1 parent 6b1ed74 commit a9fb508

24 files changed

+91
-90
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
.. tip::
3+
4+
In the :program:`mongo` Shell, this command can also be run through the
5+
|method|.
6+
7+
Helper methods are convenient for :program:`mongo` users, but they may not
8+
return the same level of information as database commands. In cases where
9+
the convenience is not needed or the additional return fields are required,
10+
use the database command.
11+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. important:: ``mongo`` Shell Method
2+
3+
This page documents a :binary:`~bin.mongo` 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+

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.rst
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.rst
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.rst
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.rst
22+
1923
The command has the following form:
20-
24+
2125
.. code-block:: javascript
2226

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

source/reference/command/explain.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Definition
2121
:dbcommand:`findAndModify`, :dbcommand:`delete`, and
2222
: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+
.. include:: /includes/fact-dbcommand-tip.rst
2727

2828
The :dbcommand:`explain` command has the following syntax:
2929

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 the
27-
:binary:`~bin.mongo` shell 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.rst
2926

3027
Syntax
3128
------

source/reference/command/findAndModify.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ 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.rst
29+
30+
.. versionchanged:: 5.0
31+
2732
The command has the following syntax:
2833

2934
.. code-block:: none

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.rst
25+
2226
The command has the following syntax:
2327

2428
.. code-block:: javascript

source/reference/command/listIndexes.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ Definition
1717

1818
Returns information about the indexes on the specified collection. Returned
1919
index information includes the keys and options used to create the index.
20-
You can optionally set the batch size for the first batch of results. The :binary:`~bin.mongo`
21-
shell provides the :method:`db.collection.getIndexes()` helper.
20+
You can optionally set the batch size for the first batch of results.
2221

22+
.. |method| replace:: :method:`db.collection.getIndexes()` helper method
23+
.. include:: /includes/fact-dbcommand-tip.rst
24+
2325
Syntax
2426
------
2527

source/reference/method/db.collection.aggregate.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ Definition
1515

1616
.. method:: db.collection.aggregate(pipeline, options)
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
18+
.. |dbcommand| replace:: :dbcommand:`aggregate` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2120

2221
Calculates aggregate values for the data in a collection or a :doc:`view </core/views>`.
2322

24-
2523
.. list-table::
2624
:header-rows: 1
2725
:widths: 20 20 80

source/reference/method/db.collection.createIndex.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ Definition
1717

1818
.. method:: db.collection.createIndex(keys, options)
1919

20-
21-
.. include:: /includes/fact-mongo-shell-method.rst
22-
20+
.. |dbcommand| replace:: :dbcommand:`createIndexes` command
21+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2322

2423
Creates indexes on collections.
2524

@@ -29,7 +28,6 @@ Definition
2928
<3.2-version-0-indexes>` indexes. To upgrade existing version 0
3029
indexes, see :ref:`3.2-version-0-indexes`.
3130

32-
3331
.. list-table::
3432
:header-rows: 1
3533
:widths: 20 20 80
@@ -115,14 +113,6 @@ Definition
115113

116114

117115

118-
119-
The :method:`db.collection.createIndex()` is a wrapper around the
120-
:dbcommand:`createIndexes` command.
121-
122-
To minimize the impact of building an index on replica sets and
123-
sharded clusters, use a rolling index build procedure as described
124-
on :doc:`/tutorial/build-indexes-on-replica-sets`.
125-
126116
.. _ensureIndex-options:
127117
.. _createIndex-options:
128118

source/reference/method/db.collection.createIndexes.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ Definition
1515

1616
.. method:: db.collection.createIndexes( [ keyPatterns ], options )
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
18+
.. |dbcommand| replace:: :dbcommand:`createIndexes` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2120

2221
.. versionadded:: 3.2
2322

2423
Creates one or more indexes on a collection.
2524

26-
2725
.. list-table::
2826
:header-rows: 1
2927
:widths: 20 20 80
@@ -108,14 +106,6 @@ Definition
108106

109107

110108

111-
112-
The :method:`db.collection.createIndexes()` is a wrapper around the
113-
:dbcommand:`createIndexes` command.
114-
115-
To minimize the impact of building an index on replica sets and sharded
116-
clusters, use a rolling index build procedure
117-
as described on :doc:`/tutorial/build-indexes-on-replica-sets`.
118-
119109
.. _createIndexes-method-options:
120110

121111
Options

source/reference/method/db.collection.distinct.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ Definition
1515

1616
.. method:: db.collection.distinct(field, query, options)
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
18+
.. |dbcommand| replace:: :dbcommand:`distinct` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2120

2221
Finds the distinct
2322
values for a specified field across a single collection or view and returns
2423
the results in an array.
2524

25+
This method takes the following parameters:
2626

2727
.. list-table::
2828
:header-rows: 1
@@ -57,11 +57,6 @@ Definition
5757
- Optional. A document that specifies the options. See :ref:`distinct-method-options`.
5858

5959

60-
61-
62-
63-
The :method:`db.collection.distinct()` method provides a wrapper
64-
around the :dbcommand:`distinct` command.
6560

6661
.. include:: /includes/note-distinct-bson-limit-agg-alternative.rst
6762

source/reference/method/db.collection.dropIndex.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ Definition
1616
.. method:: db.collection.dropIndex(index)
1717

1818

19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
21-
22-
Drops or removes the specified index from a collection. The
23-
:method:`db.collection.dropIndex()` method provides a wrapper around
24-
the :dbcommand:`dropIndexes` command.
19+
.. |dbcommand| replace:: :dbcommand:`dropIndexes` command
20+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2521

22+
Drops or removes the specified index from a collection.
23+
2624
.. note::
2725

2826
- You cannot drop the default index on the ``_id`` field.
@@ -32,6 +30,10 @@ Definition
3230
<db.collection.dropIndex>` to drop all non-``_id`` indexes. Use
3331
:method:`db.collection.dropIndexes()` instead.
3432

33+
To get the index name or the index specification document for the
34+
:method:`db.collection.dropIndex()` method, use the
35+
:method:`db.collection.getIndexes()` method.
36+
3537
The :method:`db.collection.dropIndex()` method takes the following
3638
parameter:
3739

source/reference/method/db.collection.dropIndexes.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ Definition
1616

1717
.. method:: db.collection.dropIndexes()
1818

19-
20-
.. include:: /includes/fact-mongo-shell-method.rst
21-
19+
.. |dbcommand| replace:: :dbcommand:`dropIndexes` command
20+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2221

2322
Drops the specified index or indexes (except the index on the
2423
``_id`` field) from a collection.
@@ -102,9 +101,6 @@ Definition
102101
**To drop multiple indexes** (Available starting in MongoDB
103102
4.2), specify an array of the index names.
104103

105-
The :method:`db.collection.dropIndexes()` is a wrapper around the
106-
:dbcommand:`dropIndexes` command.
107-
108104
Behavior
109105
--------
110106

source/reference/method/db.collection.explain.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ Description
1515

1616
.. method:: db.collection.explain()
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
18+
.. |dbcommand| replace:: :dbcommand:`explain` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2120

2221
Returns information on the query plan for the following methods:
2322

source/reference/method/db.collection.find.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ Definition
1515

1616
.. method:: db.collection.find(query, projection)
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
18+
.. |dbcommand| replace:: :dbcommand:`find` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2120

2221
Selects documents in a collection or view and returns a
2322
:term:`cursor` to the selected documents.
2423

25-
2624
.. list-table::
2725
:header-rows: 1
2826
:widths: 20 20 80

source/reference/method/db.collection.findAndModify.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ Definition
1919

2020
.. method:: db.collection.findAndModify(document)
2121

22-
23-
.. include:: /includes/fact-mongo-shell-method.rst
24-
25-
22+
.. |dbcommand| replace:: :dbcommand:`findAndModify` command
23+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2624

2725
Modifies and returns a single document. By default, the returned
2826
document does not include the modifications made on the update. To
2927
return the document with the modifications made on the update, use
30-
the ``new`` option. The :method:`~db.collection.findAndModify()`
31-
method is a shell helper around the :dbcommand:`findAndModify`
32-
command.
28+
the ``new`` option.
3329

3430
The :method:`~db.collection.findAndModify()` method has the following
3531
form:

source/reference/method/db.collection.findOne.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ Definition
1515

1616
.. method:: db.collection.findOne(query, projection)
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
18+
.. |dbcommand| replace:: :dbcommand:`find` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2120

2221
Returns one document that satisfies the specified query criteria on
2322
the collection or :doc:`view </core/views>`. If multiple documents

source/reference/method/db.collection.getIndexes.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ Definition
1515

1616
.. method:: db.collection.getIndexes()
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
18+
.. |dbcommand| replace:: :dbcommand:`listIndexes` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2120

2221
Returns an array that holds a list of documents that identify and
2322
describe the existing indexes on the collection. You must call
23+
24+
You must call
2425
:method:`db.collection.getIndexes()` on a collection. For example:
2526

2627
.. code-block:: javascript

source/reference/method/db.collection.insertMany.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ Definition
1515

1616
.. method:: db.collection.insertMany()
1717

18-
19-
.. include:: /includes/fact-mongo-shell-method.rst
20-
21-
22-
.. versionadded:: 3.2
18+
.. |dbcommand| replace:: :dbcommand:`insert` command
19+
.. include:: /includes/fact-mongo-shell-method-alt.rst
2320

2421
Inserts multiple documents into a collection.
2522

0 commit comments

Comments
 (0)