From 2544d9bc72d4f0eeb6b6535248dff68403a0e6c0 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Mon, 20 Sep 2021 11:03:59 -0400 Subject: [PATCH 1/2] fix(NODE-3609): correct listDatabases return type --- src/operations/list_databases.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/operations/list_databases.ts b/src/operations/list_databases.ts index d138e35910..5a5ed52927 100644 --- a/src/operations/list_databases.ts +++ b/src/operations/list_databases.ts @@ -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 { From 769855a6b1a1a2487a05e11005cea429720df69f Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 24 Sep 2021 15:24:34 -0400 Subject: [PATCH 2/2] test: add an assertion about listDatabases --- test/types/admin.test-d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/types/admin.test-d.ts diff --git a/test/types/admin.test-d.ts b/test/types/admin.test-d.ts new file mode 100644 index 0000000000..ef76c3fb40 --- /dev/null +++ b/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());