Skip to content

Commit 6a4ea3a

Browse files
DropCollection
1 parent e628296 commit 6a4ea3a

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/operations/drop.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import { MongoServerError } from '..';
1+
import { type Connection, MongoServerError } from '..';
22
import type { Document } from '../bson';
3+
import { MongoDBResponse } from '../cmap/wire_protocol/responses';
34
import { CursorTimeoutContext } from '../cursor/abstract_cursor';
45
import type { Db } from '../db';
56
import { MONGODB_ERROR_CODES } from '../error';
67
import type { Server } from '../sdam/server';
78
import type { ClientSession } from '../sessions';
89
import { TimeoutContext } from '../timeout';
9-
import { CommandOperation, type CommandOperationOptions } from './command';
10+
import {
11+
CommandOperation,
12+
type CommandOperationOptions,
13+
ModernizedCommandOperation
14+
} from './command';
1015
import { executeOperation } from './execute_operation';
1116
import { Aspect, defineAspects } from './operation';
1217

@@ -17,7 +22,9 @@ export interface DropCollectionOptions extends CommandOperationOptions {
1722
}
1823

1924
/** @internal */
20-
export class DropCollectionOperation extends CommandOperation<boolean> {
25+
export class DropCollectionOperation extends ModernizedCommandOperation<boolean> {
26+
override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;
27+
2128
override options: DropCollectionOptions;
2229
name: string;
2330

@@ -31,12 +38,11 @@ export class DropCollectionOperation extends CommandOperation<boolean> {
3138
return 'drop' as const;
3239
}
3340

34-
override async execute(
35-
server: Server,
36-
session: ClientSession | undefined,
37-
timeoutContext: TimeoutContext
38-
): Promise<boolean> {
39-
await super.executeCommand(server, session, { drop: this.name }, timeoutContext);
41+
override buildCommandDocument(_connection: Connection, _session?: ClientSession): Document {
42+
return { drop: this.name };
43+
}
44+
45+
override handleOk(_response: InstanceType<typeof this.SERVER_COMMAND_RESPONSE_TYPE>): boolean {
4046
return true;
4147
}
4248
}

0 commit comments

Comments
 (0)