File tree Expand file tree Collapse file tree 3 files changed +224
-0
lines changed
Expand file tree Collapse file tree 3 files changed +224
-0
lines changed Original file line number Diff line number Diff line change @@ -427,6 +427,16 @@ class DistinctOptions {
427427 * and providing one will result in a server-side error.
428428 */
429429 comment: Optional<any>;
430+
431+ /**
432+ * The index to use. Specify either the index name as a string or the index key pattern.
433+ * If specified, then the query system will only consider plans using the hinted index.
434+ *
435+ * This option is sent only if the caller explicitly provides a value. The default is to not send a value.
436+ *
437+ * @see https://www.mongodb.com/docs/manual/reference/command/find/
438+ */
439+ hint: Optional<(String | Document)>;
430440}
431441
432442enum CursorType {
@@ -2488,6 +2498,8 @@ aforementioned allowance in the SemVer spec.
24882498
24892499- 2024-11-04: Always send a value for ` bypassDocumentValidation ` if it was specified.
24902500
2501+ - 2024-11-01: Add hint to DistinctOptions
2502+
24912503- 2024-10-30: Document query limitations in ` countDocuments ` .
24922504
24932505- 2024-10-28: Clarified that generated identifiers should be prepended to documents.
Original file line number Diff line number Diff line change 1+ description : " distinct-hint"
2+
3+ schemaVersion : " 1.0"
4+ runOnRequirements :
5+ # https://jira.mongodb.org/browse/SERVER-14227
6+ # Server supports distinct with hint starting from 7.1.0.
7+ - minServerVersion : " 7.1.0"
8+
9+ createEntities :
10+ - client :
11+ id : &client0 client0
12+ observeEvents : [ commandStartedEvent ]
13+ - database :
14+ id : &database0 database0
15+ client : *client0
16+ databaseName : &database0Name distinct-hint-tests
17+ - collection :
18+ id : &collection0 collection0
19+ database : *database0
20+ collectionName : &collection0Name coll0
21+
22+ initialData :
23+ - collectionName : *collection0Name
24+ databaseName : *database0Name
25+ documents :
26+ - { _id: 1, x: 11 }
27+ - { _id: 2, x: 22 }
28+ - { _id: 3, x: 33 }
29+
30+ tests :
31+ - description : " distinct with hint string"
32+ operations :
33+ - name : distinct
34+ object : *collection0
35+ arguments :
36+ fieldName : &fieldName x
37+ filter : &filter { _id: 1 }
38+ hint : _id_
39+ expectResult : [ 11 ]
40+ expectEvents :
41+ - client : *client0
42+ events :
43+ - commandStartedEvent :
44+ command :
45+ distinct : *collection0Name
46+ key : *fieldName
47+ query : *filter
48+ hint : _id_
49+ commandName : distinct
50+ databaseName : *database0Name
51+
52+ - description : " distinct with hint document"
53+ operations :
54+ - name : distinct
55+ object : *collection0
56+ arguments :
57+ fieldName : *fieldName
58+ filter : *filter
59+ hint :
60+ _id : 1
61+ expectResult : [ 11 ]
62+ expectEvents :
63+ - client : *client0
64+ events :
65+ - commandStartedEvent :
66+ command :
67+ distinct : *collection0Name
68+ key : *fieldName
69+ query : *filter
70+ hint :
71+ _id : 1
72+ commandName : distinct
73+ databaseName : *database0Name
You can’t perform that action at this time.
0 commit comments