stats.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use strict';
  2. const Aspect = require('./operation').Aspect;
  3. const CommandOperation = require('./command');
  4. const defineAspects = require('./operation').defineAspects;
  5. /**
  6. * Get all the collection statistics.
  7. *
  8. * @class
  9. * @property {Collection} a Collection instance.
  10. * @property {object} [options] Optional settings. See Collection.prototype.stats for a list of options.
  11. */
  12. class StatsOperation extends CommandOperation {
  13. /**
  14. * Construct a Stats operation.
  15. *
  16. * @param {Collection} a Collection instance.
  17. * @param {object} [options] Optional settings. See Collection.prototype.stats for a list of options.
  18. */
  19. constructor(collection, options) {
  20. super(collection.s.db, options, collection);
  21. }
  22. _buildCommand() {
  23. const collection = this.collection;
  24. const options = this.options;
  25. // Build command object
  26. const command = {
  27. collStats: collection.collectionName
  28. };
  29. // Check if we have the scale value
  30. if (options['scale'] != null) {
  31. command['scale'] = options['scale'];
  32. }
  33. return command;
  34. }
  35. }
  36. defineAspects(StatsOperation, Aspect.READ_OPERATION);
  37. module.exports = StatsOperation;