|
1 | 1 | import type { BSONSerializeOptions, Document } from '../bson';
|
2 | 2 | import { type Connection } from '../cmap/connection';
|
3 |
| -import { MongoDBResponse, type MongoDBResponseConstructor } from '../cmap/wire_protocol/responses'; |
| 3 | +import { CursorResponse, MongoDBResponse, type MongoDBResponseConstructor } from '../cmap/wire_protocol/responses'; |
4 | 4 | import { type Db } from '../db';
|
5 | 5 | import type { ReadPreferenceLike } from '../read_preference';
|
6 | 6 | import type { ServerCommandOptions } from '../sdam/server';
|
@@ -54,6 +54,41 @@ export class RunCommandOperation<T = Document> extends ModernizedOperation<T> {
|
54 | 54 | }
|
55 | 55 | }
|
56 | 56 |
|
| 57 | +/** @internal */ |
| 58 | +export class RunCursorCommandOperation extends ModernizedOperation<CursorResponse> { |
| 59 | + override SERVER_COMMAND_RESPONSE_TYPE = CursorResponse; |
| 60 | + command: Document; |
| 61 | + override options: RunCommandOptions & { responseType?: MongoDBResponseConstructor }; |
| 62 | + |
| 63 | + constructor( |
| 64 | + parent: Db, |
| 65 | + command: Document, |
| 66 | + options: RunCommandOptions & { responseType?: MongoDBResponseConstructor } |
| 67 | + ) { |
| 68 | + super(options); |
| 69 | + this.command = command; |
| 70 | + this.options = options; |
| 71 | + this.ns = parent.s.namespace.withCollection('$cmd'); |
| 72 | + } |
| 73 | + |
| 74 | + override get commandName() { |
| 75 | + return 'runCommand' as const; |
| 76 | + } |
| 77 | + |
| 78 | + override buildCommand(_connection: Connection, _session?: ClientSession): Document { |
| 79 | + return this.command; |
| 80 | + } |
| 81 | + |
| 82 | + override buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions { |
| 83 | + return { session: this.session, timeoutContext }; |
| 84 | + } |
| 85 | + override handleOk( |
| 86 | + response: InstanceType<typeof this.SERVER_COMMAND_RESPONSE_TYPE> |
| 87 | + ): CursorResponse { |
| 88 | + return response; |
| 89 | + } |
| 90 | +} |
| 91 | + |
57 | 92 | export class RunAdminCommandOperation<T = Document> extends ModernizedOperation<T> {
|
58 | 93 | override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;
|
59 | 94 | command: Document;
|
|
0 commit comments