- Reference >
- JavaScript Methods >
- cursor.hint()
cursor.hint()¶
-
cursor.hint(index)¶ Arguments: - index –
The index to “hint” or force MongoDB to use when performing the query.
Specify the index either by the index name or by the index specification document. See Index Specification Documents for information on index specification documents.
Call this method on a query to override MongoDB’s default index selection and query optimization process. Use
db.collection.getIndexes()to return the list of current indexes on a collection.Consider the following operation:
This operation returns all documents in the collection named
usersusing the index on theagefield.You can also specify the index using the index name:
See also
- index –