From a8e9938abcb00b67816438fb7c9db890e35d63c9 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 24 Sep 2021 17:46:54 -0400 Subject: [PATCH] fix(NODE-3609): correct listDatabases return type (#2986) --- src/operations/list_databases.ts | 7 ++++++- test/types/admin.test-d.ts | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/types/admin.test-d.ts 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 { 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());