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 authored and ljhaywar committed Nov 9, 2021
1 parent c869479 commit 1557842
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 1557842

Please sign in to comment.