drop.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.DropSearchIndexOperation = void 0;
  4. const responses_1 = require("../../cmap/wire_protocol/responses");
  5. const error_1 = require("../../error");
  6. const operation_1 = require("../operation");
  7. /** @internal */
  8. class DropSearchIndexOperation extends operation_1.AbstractOperation {
  9. constructor(collection, name) {
  10. super();
  11. this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
  12. this.collection = collection;
  13. this.name = name;
  14. this.ns = collection.fullNamespace;
  15. }
  16. get commandName() {
  17. return 'dropSearchIndex';
  18. }
  19. buildCommand(_connection, _session) {
  20. const namespace = this.collection.fullNamespace;
  21. const command = {
  22. dropSearchIndex: namespace.collection
  23. };
  24. if (typeof this.name === 'string') {
  25. command.name = this.name;
  26. }
  27. return command;
  28. }
  29. handleOk(_response) {
  30. // do nothing
  31. }
  32. buildOptions(timeoutContext) {
  33. return { session: this.session, timeoutContext };
  34. }
  35. handleError(error) {
  36. const isNamespaceNotFoundError = error instanceof error_1.MongoServerError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound;
  37. if (!isNamespaceNotFoundError) {
  38. throw error;
  39. }
  40. }
  41. }
  42. exports.DropSearchIndexOperation = DropSearchIndexOperation;
  43. //# sourceMappingURL=drop.js.map