@@ -683,11 +683,13 @@ export class Collection<TSchema extends Document = Document> {
683
683
options ?: IndexInformationOptions
684
684
) : Promise < boolean > {
685
685
const indexNames : string [ ] = [ indexes ] . flat ( ) ;
686
- const allIndexes : string [ ] = await this . listIndexes ( options )
687
- . map ( ( { name } ) => name )
688
- . toArray ( ) ;
686
+ const allIndexes : Set < string > = new Set (
687
+ await this . listIndexes ( options )
688
+ . map ( ( { name } ) => name )
689
+ . toArray ( )
690
+ ) ;
689
691
690
- return setDifference ( indexNames , allIndexes ) . size === 0 ;
692
+ return indexNames . every ( name => allIndexes . has ( name ) ) ;
691
693
}
692
694
693
695
/**
@@ -696,12 +698,7 @@ export class Collection<TSchema extends Document = Document> {
696
698
* @param options - Optional settings for the command
697
699
*/
698
700
async indexInformation ( options ?: IndexInformationOptions ) : Promise < Document > {
699
- const resolvedOptions : IndexInformationOptions = {
700
- readPreference : options ?. readPreference ,
701
- session : options ?. session ,
702
- full : false
703
- } ;
704
- return this . indexes ( resolvedOptions ) ;
701
+ return this . indexes ( { ...options , full : options ?. full ?? false } ) ;
705
702
}
706
703
707
704
/**
@@ -807,7 +804,7 @@ export class Collection<TSchema extends Document = Document> {
807
804
*/
808
805
async indexes ( options ?: IndexInformationOptions ) : Promise < Document [ ] > {
809
806
const indexes = await this . listIndexes ( options ) . toArray ( ) ;
810
- const full = options ?. full === true ;
807
+ const full = options ?. full ?? true === true ;
811
808
if ( full ) {
812
809
return indexes ;
813
810
}
0 commit comments