1
+ import { type Connection } from '..' ;
1
2
import type { Document } from '../bson' ;
3
+ import { MongoDBResponse } from '../cmap/wire_protocol/responses' ;
2
4
import type { Db } from '../db' ;
3
- import { type TODO_NODE_3286 } from '../mongo_types' ;
4
- import type { Server } from '../sdam/server' ;
5
5
import type { ClientSession } from '../sessions' ;
6
- import { type TimeoutContext } from '../timeout' ;
7
6
import { maxWireVersion , MongoDBNamespace } from '../utils' ;
8
- import { CommandOperation , type CommandOperationOptions } from './command' ;
7
+ import { type CommandOperationOptions , ModernizedCommandOperation } from './command' ;
9
8
import { Aspect , defineAspects } from './operation' ;
10
9
11
10
/** @public */
@@ -27,7 +26,8 @@ export interface ListDatabasesOptions extends CommandOperationOptions {
27
26
}
28
27
29
28
/** @internal */
30
- export class ListDatabasesOperation extends CommandOperation < ListDatabasesResult > {
29
+ export class ListDatabasesOperation extends ModernizedCommandOperation < ListDatabasesResult > {
30
+ override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse ;
31
31
override options : ListDatabasesOptions ;
32
32
33
33
constructor ( db : Db , options ?: ListDatabasesOptions ) {
@@ -40,11 +40,7 @@ export class ListDatabasesOperation extends CommandOperation<ListDatabasesResult
40
40
return 'listDatabases' as const ;
41
41
}
42
42
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 {
48
44
const cmd : Document = { listDatabases : 1 } ;
49
45
50
46
if ( typeof this . options . nameOnly === 'boolean' ) {
@@ -61,16 +57,11 @@ export class ListDatabasesOperation extends CommandOperation<ListDatabasesResult
61
57
62
58
// we check for undefined specifically here to allow falsy values
63
59
// 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 ) {
65
61
cmd . comment = this . options . comment ;
66
62
}
67
63
68
- return await ( super . executeCommand (
69
- server ,
70
- session ,
71
- cmd ,
72
- timeoutContext
73
- ) as Promise < TODO_NODE_3286 > ) ;
64
+ return cmd ;
74
65
}
75
66
}
76
67
0 commit comments