create.js 1.1 KB

1234567891011121314151617181920212223242526272829
  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.AbstractCallbackOperation {
  7. constructor(collection, descriptions) {
  8. super();
  9. this.collection = collection;
  10. this.descriptions = descriptions;
  11. }
  12. executeCallback(server, session, callback) {
  13. const namespace = this.collection.fullNamespace;
  14. const command = {
  15. createSearchIndexes: namespace.collection,
  16. indexes: this.descriptions
  17. };
  18. server.command(namespace, command, { session }, (err, res) => {
  19. if (err || !res) {
  20. callback(err);
  21. return;
  22. }
  23. const indexesCreated = res?.indexesCreated ?? [];
  24. callback(undefined, indexesCreated.map(({ name }) => name));
  25. });
  26. }
  27. }
  28. exports.CreateSearchIndexesOperation = CreateSearchIndexesOperation;
  29. //# sourceMappingURL=create.js.map