@@ -68,7 +68,7 @@ import type {
6868} from '@mongodb-js/compass-connections/provider' ;
6969import type { Query , QueryBarService } from '@mongodb-js/compass-query-bar' ;
7070import type { TrackFunction } from '@mongodb-js/compass-telemetry' ;
71- import type { MongoServerError } from 'mongodb' ;
71+ import type { CollationOptions , MongoServerError } from 'mongodb' ;
7272
7373export type BSONObject = TypeCastMap [ 'Object' ] ;
7474export type BSONArray = TypeCastMap [ 'Array' ] ;
@@ -589,7 +589,7 @@ class CrudStoreImpl
589589 if ( id !== undefined ) {
590590 doc . onRemoveStart ( ) ;
591591 try {
592- await this . dataService . deleteOne ( this . state . ns , { _id : id } as any ) ;
592+ await this . dataService . deleteOne ( this . state . ns , { _id : id as any } ) ;
593593 // emit on the document(list view) and success state(json view)
594594 doc . onRemoveSuccess ( ) ;
595595 const payload = { view : this . state . view , ns : this . state . ns } ;
@@ -866,6 +866,7 @@ class CrudStoreImpl
866866 filter,
867867 limit,
868868 sort,
869+ hint,
869870 project : projection ,
870871 collation,
871872 maxTimeMS,
@@ -894,9 +895,10 @@ class CrudStoreImpl
894895 const opts = {
895896 skip,
896897 limit : nextPageCount ,
897- sort,
898- projection,
899- collation,
898+ hint : hint ?? undefined ,
899+ sort : sort ?? undefined ,
900+ projection : projection ?? undefined ,
901+ collation : collation as CollationOptions ,
900902 maxTimeMS : capMaxTimeMSAtPreferenceLimit ( this . preferences , maxTimeMS ) ,
901903 promoteValues : false ,
902904 bsonRegExp : true ,
@@ -920,7 +922,7 @@ class CrudStoreImpl
920922 this . state . isDataLake ,
921923 ns ,
922924 filter ?? { } ,
923- opts as any ,
925+ opts ,
924926 {
925927 abortSignal : signal ,
926928 }
@@ -1649,9 +1651,14 @@ class CrudStoreImpl
16491651 : query . maxTimeMS
16501652 ) ,
16511653 signal,
1654+ ...( query . hint
1655+ ? {
1656+ hint : query . hint ,
1657+ }
1658+ : { } ) ,
16521659 } ;
16531660
1654- if ( this . isCountHintSafe ( query ) ) {
1661+ if ( ! countOptions . hint && this . isCountHintSafe ( query ) ) {
16551662 countOptions . hint = '_id_' ;
16561663 }
16571664
@@ -1671,11 +1678,12 @@ class CrudStoreImpl
16711678 }
16721679
16731680 const findOptions = {
1674- sort,
1675- projection : query . project ,
1681+ sort : sort ?? undefined ,
1682+ projection : query . project ?? undefined ,
16761683 skip : query . skip ,
16771684 limit : docsPerPage ,
1678- collation : query . collation ,
1685+ collation : query . collation as CollationOptions ,
1686+ hint : query . hint ?? undefined ,
16791687 maxTimeMS : capMaxTimeMSAtPreferenceLimit (
16801688 this . preferences ,
16811689 query . maxTimeMS
@@ -1705,7 +1713,7 @@ class CrudStoreImpl
17051713 // Only check if index was used if query filter or sort is not empty
17061714 if ( ! isEmpty ( query . filter ) || ! isEmpty ( query . sort ) ) {
17071715 void this . dataService
1708- . explainFind ( ns , query . filter ?? { } , findOptions as any , {
1716+ . explainFind ( ns , query . filter ?? { } , findOptions , {
17091717 explainVerbosity : 'queryPlanner' ,
17101718 abortSignal : signal ,
17111719 } )
@@ -1772,7 +1780,7 @@ class CrudStoreImpl
17721780 this . state . isDataLake ,
17731781 ns ,
17741782 query . filter ?? { } ,
1775- findOptions as any ,
1783+ findOptions ,
17761784 {
17771785 abortSignal : signal ,
17781786 }
0 commit comments