Skip to content

Commit 8d9f862

Browse files
listdatabases
1 parent 632dab4 commit 8d9f862

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/operations/list_databases.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { type Connection } from '..';
12
import type { Document } from '../bson';
3+
import { MongoDBResponse } from '../cmap/wire_protocol/responses';
24
import type { Db } from '../db';
3-
import { type TODO_NODE_3286 } from '../mongo_types';
4-
import type { Server } from '../sdam/server';
55
import type { ClientSession } from '../sessions';
6-
import { type TimeoutContext } from '../timeout';
76
import { maxWireVersion, MongoDBNamespace } from '../utils';
8-
import { CommandOperation, type CommandOperationOptions } from './command';
7+
import { type CommandOperationOptions, ModernizedCommandOperation } from './command';
98
import { Aspect, defineAspects } from './operation';
109

1110
/** @public */
@@ -27,7 +26,8 @@ export interface ListDatabasesOptions extends CommandOperationOptions {
2726
}
2827

2928
/** @internal */
30-
export class ListDatabasesOperation extends CommandOperation<ListDatabasesResult> {
29+
export class ListDatabasesOperation extends ModernizedCommandOperation<ListDatabasesResult> {
30+
override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;
3131
override options: ListDatabasesOptions;
3232

3333
constructor(db: Db, options?: ListDatabasesOptions) {
@@ -40,11 +40,7 @@ export class ListDatabasesOperation extends CommandOperation<ListDatabasesResult
4040
return 'listDatabases' as const;
4141
}
4242

43-
override async execute(
44-
server: Server,
45-
session: ClientSession | undefined,
46-
timeoutContext: TimeoutContext
47-
): Promise<ListDatabasesResult> {
43+
override buildCommandDocument(connection: Connection, _session?: ClientSession): Document {
4844
const cmd: Document = { listDatabases: 1 };
4945

5046
if (typeof this.options.nameOnly === 'boolean') {
@@ -61,16 +57,11 @@ export class ListDatabasesOperation extends CommandOperation<ListDatabasesResult
6157

6258
// we check for undefined specifically here to allow falsy values
6359
// eslint-disable-next-line no-restricted-syntax
64-
if (maxWireVersion(server) >= 9 && this.options.comment !== undefined) {
60+
if (maxWireVersion(connection) >= 9 && this.options.comment !== undefined) {
6561
cmd.comment = this.options.comment;
6662
}
6763

68-
return await (super.executeCommand(
69-
server,
70-
session,
71-
cmd,
72-
timeoutContext
73-
) as Promise<TODO_NODE_3286>);
64+
return cmd;
7465
}
7566
}
7667

0 commit comments

Comments
 (0)