create.js 937 B

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CreateSearchIndexesOperation = void 0;
  4. const operation_1 = require("../operation");
  5. /** @internal */
  6. class CreateSearchIndexesOperation extends operation_1.AbstractOperation {
  7. constructor(collection, descriptions) {
  8. super();
  9. this.collection = collection;
  10. this.descriptions = descriptions;
  11. }
  12. async execute(server, session) {
  13. const namespace = this.collection.fullNamespace;
  14. const command = {
  15. createSearchIndexes: namespace.collection,
  16. indexes: this.descriptions
  17. };
  18. const res = await server.commandAsync(namespace, command, { session });
  19. const indexesCreated = res?.indexesCreated ?? [];
  20. return indexesCreated.map(({ name }) => name);
  21. }
  22. }
  23. exports.CreateSearchIndexesOperation = CreateSearchIndexesOperation;
  24. //# sourceMappingURL=create.js.map