drop.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.DropSearchIndexOperation = void 0;
  4. const error_1 = require("../../error");
  5. const operation_1 = require("../operation");
  6. /** @internal */
  7. class DropSearchIndexOperation extends operation_1.AbstractOperation {
  8. constructor(collection, name) {
  9. super();
  10. this.collection = collection;
  11. this.name = name;
  12. }
  13. async execute(server, session) {
  14. const namespace = this.collection.fullNamespace;
  15. const command = {
  16. dropSearchIndex: namespace.collection
  17. };
  18. if (typeof this.name === 'string') {
  19. command.name = this.name;
  20. }
  21. try {
  22. await server.commandAsync(namespace, command, { session });
  23. }
  24. catch (error) {
  25. const isNamespaceNotFoundError = error instanceof error_1.MongoServerError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound;
  26. if (!isNamespaceNotFoundError) {
  27. throw error;
  28. }
  29. }
  30. }
  31. }
  32. exports.DropSearchIndexOperation = DropSearchIndexOperation;
  33. //# sourceMappingURL=drop.js.map