File tree Expand file tree Collapse file tree 2 files changed +12
-22
lines changed Expand file tree Collapse file tree 2 files changed +12
-22
lines changed Original file line number Diff line number Diff line change @@ -683,13 +683,11 @@ 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 : Set < string > = new Set (
687
- await this . listIndexes ( options )
688
- . map ( ( { name } ) => name )
689
- . toArray ( )
690
- ) ;
686
+ const allIndexes : string [ ] = await this . listIndexes ( options )
687
+ . map ( ( { name } ) => name )
688
+ . toArray ( ) ;
691
689
692
- return indexNames . every ( name => allIndexes . has ( name ) ) ;
690
+ return indexNames . every ( name => allIndexes . includes ( name ) ) ;
693
691
}
694
692
695
693
/**
@@ -804,7 +802,7 @@ export class Collection<TSchema extends Document = Document> {
804
802
*/
805
803
async indexes ( options ?: IndexInformationOptions ) : Promise < Document [ ] > {
806
804
const indexes = await this . listIndexes ( options ) . toArray ( ) ;
807
- const full = options ?. full ?? true === true ;
805
+ const full = options ?. full ?? true ;
808
806
if ( full ) {
809
807
return indexes ;
810
808
}
Original file line number Diff line number Diff line change @@ -286,14 +286,10 @@ describe('Indexes', function () {
286
286
} ) ;
287
287
288
288
context ( 'when dropIndexes fails' , function ( ) {
289
- let collection ;
290
-
291
289
beforeEach ( async function ( ) {
292
- collection = await db . createCollection ( 'test_drop_indexes' ) ;
293
- await collection . insert ( { a : 1 } ) ;
290
+ await collection . insertOne ( { a : 1 } ) ;
294
291
// Create an index on the collection
295
- await db . createIndex ( collection . collectionName , 'a' ) ;
296
- /**@type {import('../tools/utils').FailPoint } */
292
+ await collection . createIndex ( 'a' ) ;
297
293
await client
298
294
. db ( )
299
295
. admin ( )
@@ -309,22 +305,18 @@ describe('Indexes', function () {
309
305
} ) ;
310
306
} ) ;
311
307
312
- afterEach ( async function ( ) {
313
- await db . dropCollection ( 'test_drop_indexes' ) ;
314
- } ) ;
315
-
316
- it ( 'should return false' , {
317
- metadata : {
308
+ it (
309
+ 'should return false' ,
310
+ {
318
311
requires : {
319
312
mongodb : '>4.0'
320
313
}
321
314
} ,
322
-
323
- test : async function ( ) {
315
+ async function ( ) {
324
316
const result = await collection . dropIndexes ( ) ;
325
317
expect ( result ) . to . equal ( false ) ;
326
318
}
327
- } ) ;
319
+ ) ;
328
320
} ) ;
329
321
330
322
context ( 'indexExists' , function ( ) {
You can’t perform that action at this time.
0 commit comments