explain.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Explain = exports.ExplainVerbosity = void 0;
  4. const error_1 = require("./error");
  5. /** @public */
  6. exports.ExplainVerbosity = Object.freeze({
  7. queryPlanner: 'queryPlanner',
  8. queryPlannerExtended: 'queryPlannerExtended',
  9. executionStats: 'executionStats',
  10. allPlansExecution: 'allPlansExecution'
  11. });
  12. /** @internal */
  13. class Explain {
  14. constructor(verbosity) {
  15. if (typeof verbosity === 'boolean') {
  16. this.verbosity = verbosity
  17. ? exports.ExplainVerbosity.allPlansExecution
  18. : exports.ExplainVerbosity.queryPlanner;
  19. }
  20. else {
  21. this.verbosity = verbosity;
  22. }
  23. }
  24. static fromOptions(options) {
  25. if ((options === null || options === void 0 ? void 0 : options.explain) == null)
  26. return;
  27. const explain = options.explain;
  28. if (typeof explain === 'boolean' || typeof explain === 'string') {
  29. return new Explain(explain);
  30. }
  31. throw new error_1.MongoInvalidArgumentError('Field "explain" must be a string or a boolean');
  32. }
  33. }
  34. exports.Explain = Explain;
  35. //# sourceMappingURL=explain.js.map