profiling_level.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ProfilingLevelOperation = void 0;
  4. const error_1 = require("../error");
  5. const command_1 = require("./command");
  6. /** @internal */
  7. class ProfilingLevelOperation extends command_1.CommandOperation {
  8. constructor(db, options) {
  9. super(db, options);
  10. this.options = options;
  11. }
  12. async execute(server, session) {
  13. const doc = await super.executeCommand(server, session, { profile: -1 });
  14. if (doc.ok === 1) {
  15. const was = doc.was;
  16. if (was === 0)
  17. return 'off';
  18. if (was === 1)
  19. return 'slow_only';
  20. if (was === 2)
  21. return 'all';
  22. throw new error_1.MongoUnexpectedServerResponseError(`Illegal profiling level value ${was}`);
  23. }
  24. else {
  25. throw new error_1.MongoUnexpectedServerResponseError('Error with profile command');
  26. }
  27. }
  28. }
  29. exports.ProfilingLevelOperation = ProfilingLevelOperation;
  30. //# sourceMappingURL=profiling_level.js.map