run_command.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.RunAdminCommandOperation = exports.RunCommandOperation = void 0;
  4. const utils_1 = require("../utils");
  5. const operation_1 = require("./operation");
  6. /** @internal */
  7. class RunCommandOperation extends operation_1.AbstractOperation {
  8. constructor(parent, command, options) {
  9. super(options);
  10. this.command = command;
  11. this.options = options;
  12. this.ns = parent.s.namespace.withCollection('$cmd');
  13. }
  14. async execute(server, session) {
  15. this.server = server;
  16. return server.commandAsync(this.ns, this.command, {
  17. ...this.options,
  18. readPreference: this.readPreference,
  19. session
  20. });
  21. }
  22. }
  23. exports.RunCommandOperation = RunCommandOperation;
  24. class RunAdminCommandOperation extends operation_1.AbstractOperation {
  25. constructor(command, options) {
  26. super(options);
  27. this.command = command;
  28. this.options = options;
  29. this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
  30. }
  31. async execute(server, session) {
  32. this.server = server;
  33. return server.commandAsync(this.ns, this.command, {
  34. ...this.options,
  35. readPreference: this.readPreference,
  36. session
  37. });
  38. }
  39. }
  40. exports.RunAdminCommandOperation = RunAdminCommandOperation;
  41. //# sourceMappingURL=run_command.js.map