Skip to content

Commit 4ec299b

Browse files
misc fixes
1 parent 8d1f965 commit 4ec299b

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

src/collection.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,11 @@ export class Collection<TSchema extends Document = Document> {
683683
options?: IndexInformationOptions
684684
): Promise<boolean> {
685685
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();
691689

692-
return indexNames.every(name => allIndexes.has(name));
690+
return indexNames.every(name => allIndexes.includes(name));
693691
}
694692

695693
/**
@@ -804,7 +802,7 @@ export class Collection<TSchema extends Document = Document> {
804802
*/
805803
async indexes(options?: IndexInformationOptions): Promise<Document[]> {
806804
const indexes = await this.listIndexes(options).toArray();
807-
const full = options?.full ?? true === true;
805+
const full = options?.full ?? true;
808806
if (full) {
809807
return indexes;
810808
}

test/integration/index_management.test.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,10 @@ describe('Indexes', function () {
286286
});
287287

288288
context('when dropIndexes fails', function () {
289-
let collection;
290-
291289
beforeEach(async function () {
292-
collection = await db.createCollection('test_drop_indexes');
293-
await collection.insert({ a: 1 });
290+
await collection.insertOne({ a: 1 });
294291
// Create an index on the collection
295-
await db.createIndex(collection.collectionName, 'a');
296-
/**@type {import('../tools/utils').FailPoint} */
292+
await collection.createIndex('a');
297293
await client
298294
.db()
299295
.admin()
@@ -309,22 +305,18 @@ describe('Indexes', function () {
309305
});
310306
});
311307

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+
{
318311
requires: {
319312
mongodb: '>4.0'
320313
}
321314
},
322-
323-
test: async function () {
315+
async function () {
324316
const result = await collection.dropIndexes();
325317
expect(result).to.equal(false);
326318
}
327-
});
319+
);
328320
});
329321

330322
context('indexExists', function () {

0 commit comments

Comments
 (0)