Skip to content

Commit

Permalink
fix(NODE-3609): correct listDatabases return type (#2986)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Sep 24, 2021
1 parent dc3e06a commit a8e9938
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/operations/list_databases.ts
Expand Up @@ -7,7 +7,12 @@ import type { Db } from '../db';
import type { ClientSession } from '../sessions';

/** @public */
export type ListDatabasesResult = string[] | Document[];
export interface ListDatabasesResult {
databases: ({ name: string; sizeOnDisk?: number; empty?: boolean } & Document)[];
totalSize?: number;
totalSizeMb?: number;
ok: 1 | 0;
}

/** @public */
export interface ListDatabasesOptions extends CommandOperationOptions {
Expand Down
12 changes: 12 additions & 0 deletions test/types/admin.test-d.ts
@@ -0,0 +1,12 @@
import { expectType } from 'tsd';
import { Document, MongoClient } from '../../src/index';

const client = new MongoClient('');
const admin = client.db().admin();

expectType<{
databases: ({ name: string; sizeOnDisk?: number; empty?: boolean } & Document)[];
totalSize?: number;
totalSizeMb?: number;
ok: 1 | 0;
}>(await admin.listDatabases());

0 comments on commit a8e9938

Please sign in to comment.