Skip to content

Commit 3fd26fe

Browse files
committed
fix: ts and lint
1 parent 78f6e72 commit 3fd26fe

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/operations/is_capped.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class IsCappedOperation extends AbstractOperation<boolean> {
2222
coll.s.db
2323
.listCollections(
2424
{ name: coll.collectionName },
25-
{ ...this.options, readPreference: this.readPreference, session }
25+
{ ...this.options, nameOnly: false, readPreference: this.readPreference, session }
2626
)
2727
.toArray((err, collections) => {
2828
if (err || !collections) return callback(err);

src/operations/options_operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class OptionsOperation extends AbstractOperation<Document> {
2323
coll.s.db
2424
.listCollections(
2525
{ name: coll.collectionName },
26-
{ ...this.options, readPreference: this.readPreference, session }
26+
{ ...this.options, nameOnly: false, readPreference: this.readPreference, session }
2727
)
2828
.toArray((err, collections) => {
2929
if (err || !collections) return callback(err);

test/types/list_collections.test-d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import type { CollectionInfo, ListCollectionsCursor } from '../../src/operations
55

66
const db = new MongoClient('').db();
77

8+
type EitherCollectionInfoResult = CollectionInfo | Pick<CollectionInfo, 'name' | 'type'>;
9+
810
// We default to the CollectionInfo result type
911
expectType<ListCollectionsCursor<Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo>>(
1012
db.listCollections()
@@ -19,7 +21,7 @@ db.listCollections({ a: 2 });
1921
db.listCollections({ a: 2 }, { batchSize: 2 });
2022

2123
const collections = await db.listCollections().toArray();
22-
expectType<(CollectionInfo | string)[]>(collections);
24+
expectType<EitherCollectionInfoResult[]>(collections);
2325

2426
const nameOnly = await db.listCollections({}, { nameOnly: true }).toArray();
2527
expectType<Pick<CollectionInfo, 'name' | 'type'>[]>(nameOnly);
@@ -28,7 +30,7 @@ const fullInfo = await db.listCollections({}, { nameOnly: false }).toArray();
2830
expectType<CollectionInfo[]>(fullInfo);
2931

3032
const couldBeEither = await db.listCollections({}, { nameOnly: Math.random() > 0.5 }).toArray();
31-
expectType<(CollectionInfo | string)[]>(couldBeEither);
33+
expectType<EitherCollectionInfoResult[]>(couldBeEither);
3234

3335
// Showing here that:
3436
// regardless of the option the generic parameter can be used to coerce the result if need be

0 commit comments

Comments
 (0)