stats.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.DbStatsOperation = exports.CollStatsOperation = void 0;
  4. const command_1 = require("./command");
  5. const operation_1 = require("./operation");
  6. /**
  7. * Get all the collection statistics.
  8. * @internal
  9. */
  10. class CollStatsOperation extends command_1.CommandOperation {
  11. /**
  12. * Construct a Stats operation.
  13. *
  14. * @param collection - Collection instance
  15. * @param options - Optional settings. See Collection.prototype.stats for a list of options.
  16. */
  17. constructor(collection, options) {
  18. super(collection, options);
  19. this.options = options !== null && options !== void 0 ? options : {};
  20. this.collectionName = collection.collectionName;
  21. }
  22. execute(server, session, callback) {
  23. const command = { collStats: this.collectionName };
  24. if (this.options.scale != null) {
  25. command.scale = this.options.scale;
  26. }
  27. super.executeCommand(server, session, command, callback);
  28. }
  29. }
  30. exports.CollStatsOperation = CollStatsOperation;
  31. /** @internal */
  32. class DbStatsOperation extends command_1.CommandOperation {
  33. constructor(db, options) {
  34. super(db, options);
  35. this.options = options;
  36. }
  37. execute(server, session, callback) {
  38. const command = { dbStats: true };
  39. if (this.options.scale != null) {
  40. command.scale = this.options.scale;
  41. }
  42. super.executeCommand(server, session, command, callback);
  43. }
  44. }
  45. exports.DbStatsOperation = DbStatsOperation;
  46. (0, operation_1.defineAspects)(CollStatsOperation, [operation_1.Aspect.READ_OPERATION]);
  47. (0, operation_1.defineAspects)(DbStatsOperation, [operation_1.Aspect.READ_OPERATION]);
  48. //# sourceMappingURL=stats.js.map