Skip to content

Commit 8a66cdb

Browse files
committed
Merge branch 'v5.5' of github.com:mongodb/docs-node into v5.5
2 parents 17fd50f + 02d2955 commit 8a66cdb

File tree

6 files changed

+50
-222
lines changed

6 files changed

+50
-222
lines changed

source/code-snippets/connection/connect.js

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { MongoClient } = require("mongodb");
2+
3+
// Replace the following with your MongoDB deployment's connection
4+
// string.
5+
const uri =
6+
"mongodb+srv://<user>:<password>@<cluster-url>?writeConcern=majority";
7+
8+
const client = new MongoClient(uri);
9+
10+
async function run(){
11+
try {
12+
const database = client.db("<database>");
13+
const collection = database.collection("<collection>");
14+
// start-listIndexes-example
15+
const result = await collection.listIndexes().toArray();
16+
console.log("Existing indexes:\n");
17+
for(const doc in result){
18+
console.log(doc);
19+
}
20+
// end-listIndexes-example
21+
}
22+
finally{
23+
await client.close();
24+
}
25+
}
26+
27+

source/code-snippets/quick-reference.js

Lines changed: 0 additions & 197 deletions
This file was deleted.

source/fundamentals/indexes.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,22 @@ the following:
312312
E11000 duplicate key error index
313313

314314
To learn more, see :manual:`Unique Indexes </core/index-unique>`.
315+
316+
List Indexes
317+
------------
318+
319+
You can use the ``listIndexes()`` method to list all of the indexes for
320+
a collection. The `listIndexes()
321+
<{+api+}/classes/Collection.html#listIndexes>`__ method takes an optional
322+
`ListIndexesOptions <{+api+}/interfaces/ListIndexesOptions.html>`__
323+
parameter. The ``listIndexes()`` method returns an object of type
324+
`ListIndexesCursor <{+api+}/classes/ListIndexesCursor.html>`__.
325+
326+
The following code uses the ``listIndexes()`` method to list all the
327+
indexes in a collection:
328+
329+
.. literalinclude:: /code-snippets/indexes/listIndexes.js
330+
:language: js
331+
:start-after: start-listIndexes-example
332+
:end-before: end-listIndexes-example
333+
:dedent:

source/includes/unicode-checkmark.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/index.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ Introduction
2727

2828
Welcome to the documentation site for the official {+driver-long+}.
2929
You can add the driver to your application to work with MongoDB
30-
in JavaScript. Download it using `npm <https://www.npmjs.com/>`__
31-
or set up a runnable project by following our Quick Start guide.
30+
in JavaScript or TypeScript. For more information about downloading and
31+
installing the {+driver-short+}, see
32+
:ref:`Download and Install <node-quick-start-download-and-install>` in the
33+
Quick Start guide.
3234

3335
Quick Start
3436
-----------

0 commit comments

Comments
 (0)