-
Notifications
You must be signed in to change notification settings - Fork 52
DOCSP-30756: add list search indexes to cursor page #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
c2a5560
6f16227
cd551bd
93e332e
b3bcf76
9363c6c
314d3c0
c4e33d5
0173472
7c177b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { MongoClient } = require("mongodb"); | ||
|
||
// Replace the following with your MongoDB deployment's connection | ||
// string. | ||
const uri = | ||
"mongodb+srv://<user>:<password>@<cluster-url>?writeConcern=majority"; | ||
|
||
const client = new MongoClient(uri); | ||
|
||
import { MongoClient } from "mongodb"; | ||
const database = client.db("<databaseName>"); | ||
const collection = database.collection("<collectionName>"); | ||
|
||
async function run() { | ||
try { | ||
// start listIndexes example | ||
const result = await collection.listIndexes().toArray(); | ||
console.log("The indexes in the collection are: "); | ||
for(const doc in result){ | ||
console.log(doc); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S: this line should be indented. Maybe re-run the formatter on your code? Also applies to other snippet |
||
} | ||
// end listIndexes example | ||
} finally { | ||
await client.close(); | ||
} | ||
} | ||
run().catch(console.dir); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { MongoClient } = require("mongodb"); | ||
|
||
// Replace the following with your MongoDB deployment's connection | ||
// string. | ||
const uri = | ||
"mongodb+srv://<user>:<password>@<cluster-url>?writeConcern=majority"; | ||
|
||
const client = new MongoClient(uri); | ||
|
||
import { MongoClient } from "mongodb"; | ||
const database = client.db("<databaseName>"); | ||
const collection = database.collection("<collectionName>"); | ||
|
||
async function run() { | ||
try { | ||
// start listSearchIndexes example | ||
const result = await collection.listSearchIndexes().toArray(); | ||
console.log("The search indexes in the collection are: "); | ||
for(const doc in result){ | ||
console.log(doc); | ||
} | ||
// end listSearchIndexes example | ||
} finally { | ||
await client.close(); | ||
} | ||
} | ||
run().catch(console.dir); |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -312,3 +312,42 @@ the following: | |||||||||
E11000 duplicate key error index | ||||||||||
|
||||||||||
To learn more, see :manual:`Unique Indexes </core/index-unique>`. | ||||||||||
|
||||||||||
List Indexes | ||||||||||
~~~~~~~~~~~~ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S: make this a header one level up, as the section is not an index type |
||||||||||
|
||||||||||
The ``listIndexes()`` method allows you to list all the indexes' | ||||||||||
information in the collection. The ``listIndexes()`` method takes an | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
optional parameter, `ListIndexesOptions | ||||||||||
<{+api+}/interfaces/ListIndexesOptions.html>`__, to set optional | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S; remove this clause of the sentence |
||||||||||
settings for the method. The ``listIndexes()`` method returns an | ||||||||||
object of type `ListIndexesCursor | ||||||||||
<{+api+}/classes/ListIndexesCursor.html>`__. | ||||||||||
|
||||||||||
The following example uses the ``listIndexes()`` method to list all the | ||||||||||
indexes' information in the collection. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S: change wording to match above suggestion from the first sentence |
||||||||||
|
||||||||||
.. literalinclude:: /code-snippets/indexes/listIndexes.js | ||||||||||
:language: javascript | ||||||||||
rustagir marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
:start-after: start listIndexes example | ||||||||||
:end-before: end listIndexes example | ||||||||||
|
||||||||||
List Search Indexes | ||||||||||
~~~~~~~~~~~~~~~~~~~ | ||||||||||
|
||||||||||
When connecting to {+mdb-server+} version 7.0 or later, you can use the new `listSearchIndexes() | ||||||||||
<https://mongodb.github.io/node-mongodb-native/Next/classes/Collection.html#listSearchIndexes>`__ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Investigating why the 5.6 docs don't cover this method |
||||||||||
method to return a cursor that contains the search indexes for the current | ||||||||||
collection. The ``listSearchIndexes()`` method takes an optional string parameter, ``name``, to | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: What does current mean in this context? Can't you just call the method on whatever collection you want? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, thank you! |
||||||||||
return only the indexes with matching index names. It also takes an | ||||||||||
optional `aggregateOptions | ||||||||||
<https://mongodb.github.io/node-mongodb-native/Next/interfaces/AggregateOptions.html>`__ | ||||||||||
parameter. | ||||||||||
|
||||||||||
The following example uses the ``listSearchIndexes()`` method to list all | ||||||||||
the search indexes in the collection. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
.. literalinclude:: /code-snippets/indexes/listSearchIndexes.js | ||||||||||
:language: javascript | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add :dedent: |
||||||||||
:start-after: start listSearchIndexes example | ||||||||||
:end-before: end listSearchIndexes example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: Per the style guide, we do not introduce lists with fragment sentences. (also applies to other file)
Perhaps something like this would be better: