@@ -17,6 +17,7 @@ import {
17
17
} from './cursor/list_search_indexes_cursor' ;
18
18
import type { Db } from './db' ;
19
19
import { MongoAPIError , MongoInvalidArgumentError , MongoOperationTimeoutError } from './error' ;
20
+ import { type ExplainCommandOptions , type ExplainVerbosityLike } from './explain' ;
20
21
import type { MongoClient , PkFactory } from './mongo_client' ;
21
22
import type {
22
23
Abortable ,
@@ -853,31 +854,32 @@ export class Collection<TSchema extends Document = Document> {
853
854
*/
854
855
distinct < Key extends keyof WithId < TSchema > > (
855
856
key : Key
856
- ) : Promise < Array < Flatten < WithId < TSchema > [ Key ] > > | Document > ;
857
+ ) : Promise < Array < Flatten < WithId < TSchema > [ Key ] > > > ;
857
858
distinct < Key extends keyof WithId < TSchema > > (
858
859
key : Key ,
859
860
filter : Filter < TSchema >
860
- ) : Promise < Array < Flatten < WithId < TSchema > [ Key ] > > | Document > ;
861
+ ) : Promise < Array < Flatten < WithId < TSchema > [ Key ] > > > ;
861
862
distinct < Key extends keyof WithId < TSchema > > (
862
863
key : Key ,
863
864
filter : Filter < TSchema > ,
864
865
options : DistinctOptions
865
- ) : Promise < Array < Flatten < WithId < TSchema > [ Key ] > > | Document > ;
866
+ ) : Promise < Array < Flatten < WithId < TSchema > [ Key ] > > > ;
867
+ distinct < Key extends keyof WithId < TSchema > > (
868
+ key : Key ,
869
+ filter : Filter < TSchema > ,
870
+ options : DistinctOptions & { explain : ExplainVerbosityLike | ExplainCommandOptions }
871
+ ) : Promise < Document > ;
866
872
867
873
// Embedded documents overload
868
- distinct ( key : string ) : Promise < any [ ] | Document > ;
869
- distinct ( key : string , filter : Filter < TSchema > ) : Promise < any [ ] | Document > ;
870
- distinct (
871
- key : string ,
872
- filter : Filter < TSchema > ,
873
- options : DistinctOptions
874
- ) : Promise < any [ ] | Document > ;
874
+ distinct ( key : string ) : Promise < any [ ] > ;
875
+ distinct ( key : string , filter : Filter < TSchema > ) : Promise < any [ ] > ;
876
+ distinct ( key : string , filter : Filter < TSchema > , options : DistinctOptions ) : Promise < any [ ] > ;
875
877
876
878
async distinct < Key extends keyof WithId < TSchema > > (
877
879
key : Key ,
878
880
filter : Filter < TSchema > = { } ,
879
881
options : DistinctOptions = { }
880
- ) : Promise < any [ ] | Document > {
882
+ ) : Promise < any [ ] > {
881
883
return await executeOperation (
882
884
this . client ,
883
885
new DistinctOperation (
0 commit comments