run_command.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.RunCursorCommandOperation = exports.RunCommandOperation = void 0;
  4. const responses_1 = require("../cmap/wire_protocol/responses");
  5. const operation_1 = require("../operations/operation");
  6. /** @internal */
  7. class RunCommandOperation extends operation_1.AbstractOperation {
  8. constructor(namespace, command, options) {
  9. super(options);
  10. this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
  11. this.command = command;
  12. this.options = options;
  13. this.ns = namespace.withCollection('$cmd');
  14. }
  15. get commandName() {
  16. return 'runCommand';
  17. }
  18. buildCommand(_connection, _session) {
  19. return this.command;
  20. }
  21. buildOptions(timeoutContext) {
  22. return {
  23. ...this.options,
  24. session: this.session,
  25. timeoutContext,
  26. signal: this.options.signal,
  27. readPreference: this.options.readPreference
  28. };
  29. }
  30. }
  31. exports.RunCommandOperation = RunCommandOperation;
  32. /**
  33. * @internal
  34. *
  35. * A specialized subclass of RunCommandOperation for cursor-creating commands.
  36. */
  37. class RunCursorCommandOperation extends RunCommandOperation {
  38. constructor() {
  39. super(...arguments);
  40. this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
  41. }
  42. handleOk(response) {
  43. return response;
  44. }
  45. }
  46. exports.RunCursorCommandOperation = RunCursorCommandOperation;
  47. //# sourceMappingURL=run_command.js.map