Skip to content

Commit dc11bf1

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-20349 add example to create indexes (#878) (#887)
* DOCSP-20349-add-example-to-createIndexes * DOCSP-20349-add-example-to-createIndexes * DOCSP-20349-add-example-to-createIndexes Co-authored-by: jason-price-mongodb <[email protected]> Co-authored-by: jason-price-mongodb <[email protected]>
1 parent aabd18f commit dc11bf1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,29 @@ majority of data-bearing voting members "vote" to commit the index
10361036
build. For more information on index builds and the voting process, see
10371037
:ref:`index-operations-replicated-build`.
10381038

1039+
Create Multiple Indexes
1040+
~~~~~~~~~~~~~~~~~~~~~~~
1041+
1042+
.. include:: /includes/cakeSales-example-collection.rst
1043+
1044+
The following example creates multiple indexes on the ``cakeSales``
1045+
collection:
1046+
1047+
.. code-block:: javascript
1048+
1049+
db.cakeSales.createIndexes( [
1050+
{ "type": 1 },
1051+
{ "orderDate": 1 },
1052+
{ "state": 1 },
1053+
{ "orderDate": 1, "state": -1 }
1054+
] )
1055+
1056+
The first three indexes are on single fields and in ascending order
1057+
(``1``).
1058+
1059+
The last index is on ``orderDate`` in ascending order (``1``) and
1060+
``state`` in descending order (``-1``).
1061+
10391062
Additional Information
10401063
----------------------
10411064

0 commit comments

Comments
 (0)