options_operation.js 994 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.OptionsOperation = void 0;
  4. const error_1 = require("../error");
  5. const operation_1 = require("./operation");
  6. /** @internal */
  7. class OptionsOperation extends operation_1.AbstractOperation {
  8. constructor(collection, options) {
  9. super(options);
  10. this.options = options;
  11. this.collection = collection;
  12. }
  13. async execute(server, session) {
  14. const coll = this.collection;
  15. const [collection] = await coll.s.db
  16. .listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
  17. .toArray();
  18. if (collection == null || collection.options == null) {
  19. throw new error_1.MongoAPIError(`collection ${coll.namespace} not found`);
  20. }
  21. return collection.options;
  22. }
  23. }
  24. exports.OptionsOperation = OptionsOperation;
  25. //# sourceMappingURL=options_operation.js.map