estimated_document_count.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.EstimatedDocumentCountOperation = void 0;
  4. const command_1 = require("./command");
  5. const operation_1 = require("./operation");
  6. /** @internal */
  7. class EstimatedDocumentCountOperation extends command_1.CommandOperation {
  8. constructor(collection, options = {}) {
  9. super(collection, options);
  10. this.options = options;
  11. this.collectionName = collection.collectionName;
  12. }
  13. execute(server, session, callback) {
  14. const cmd = { count: this.collectionName };
  15. if (typeof this.options.maxTimeMS === 'number') {
  16. cmd.maxTimeMS = this.options.maxTimeMS;
  17. }
  18. super.executeCommand(server, session, cmd, (err, response) => {
  19. if (err) {
  20. callback(err);
  21. return;
  22. }
  23. callback(undefined, (response === null || response === void 0 ? void 0 : response.n) || 0);
  24. });
  25. }
  26. }
  27. exports.EstimatedDocumentCountOperation = EstimatedDocumentCountOperation;
  28. (0, operation_1.defineAspects)(EstimatedDocumentCountOperation, [
  29. operation_1.Aspect.READ_OPERATION,
  30. operation_1.Aspect.RETRYABLE,
  31. operation_1.Aspect.CURSOR_CREATING
  32. ]);
  33. //# sourceMappingURL=estimated_document_count.js.map