Skip to content

Commit a8e9938

Browse files
authored
fix(NODE-3609): correct listDatabases return type (#2986)
1 parent dc3e06a commit a8e9938

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/operations/list_databases.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import type { Db } from '../db';
77
import type { ClientSession } from '../sessions';
88

99
/** @public */
10-
export type ListDatabasesResult = string[] | Document[];
10+
export interface ListDatabasesResult {
11+
databases: ({ name: string; sizeOnDisk?: number; empty?: boolean } & Document)[];
12+
totalSize?: number;
13+
totalSizeMb?: number;
14+
ok: 1 | 0;
15+
}
1116

1217
/** @public */
1318
export interface ListDatabasesOptions extends CommandOperationOptions {

test/types/admin.test-d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { expectType } from 'tsd';
2+
import { Document, MongoClient } from '../../src/index';
3+
4+
const client = new MongoClient('');
5+
const admin = client.db().admin();
6+
7+
expectType<{
8+
databases: ({ name: string; sizeOnDisk?: number; empty?: boolean } & Document)[];
9+
totalSize?: number;
10+
totalSizeMb?: number;
11+
ok: 1 | 0;
12+
}>(await admin.listDatabases());

0 commit comments

Comments
 (0)