-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathremove_user.ts
33 lines (28 loc) · 994 Bytes
/
remove_user.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import type { Db } from '../db';
import type { Server } from '../sdam/server';
import type { ClientSession } from '../sessions';
import type { Callback } from '../utils';
import { CommandOperation, CommandOperationOptions } from './command';
import { Aspect, defineAspects } from './operation';
/** @public */
export type RemoveUserOptions = CommandOperationOptions;
/** @internal */
export class RemoveUserOperation extends CommandOperation<boolean> {
override options: RemoveUserOptions;
username: string;
constructor(db: Db, username: string, options: RemoveUserOptions) {
super(db, options);
this.options = options;
this.username = username;
}
override execute(
server: Server,
session: ClientSession | undefined,
callback: Callback<boolean>
): void {
super.executeCommand(server, session, { dropUser: this.username }, err => {
callback(err, err ? false : true);
});
}
}
defineAspects(RemoveUserOperation, [Aspect.WRITE_OPERATION]);