remove_user.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import type { Db } from '../db';
  2. import type { Server } from '../sdam/server';
  3. import type { ClientSession } from '../sessions';
  4. import type { Callback } from '../utils';
  5. import { CommandCallbackOperation, type CommandOperationOptions } from './command';
  6. import { Aspect, defineAspects } from './operation';
  7. /** @public */
  8. export type RemoveUserOptions = CommandOperationOptions;
  9. /** @internal */
  10. export class RemoveUserOperation extends CommandCallbackOperation<boolean> {
  11. override options: RemoveUserOptions;
  12. username: string;
  13. constructor(db: Db, username: string, options: RemoveUserOptions) {
  14. super(db, options);
  15. this.options = options;
  16. this.username = username;
  17. }
  18. override executeCallback(
  19. server: Server,
  20. session: ClientSession | undefined,
  21. callback: Callback<boolean>
  22. ): void {
  23. super.executeCommandCallback(server, session, { dropUser: this.username }, err => {
  24. callback(err, err ? false : true);
  25. });
  26. }
  27. }
  28. defineAspects(RemoveUserOperation, [Aspect.WRITE_OPERATION]);