options_operation.js 1.1 KB

1234567891011121314151617181920212223242526272829
  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. execute(server, session, callback) {
  14. const coll = this.collection;
  15. coll.s.db
  16. .listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session })
  17. .toArray((err, collections) => {
  18. if (err || !collections)
  19. return callback(err);
  20. if (collections.length === 0) {
  21. // TODO(NODE-3485)
  22. return callback(new error_1.MongoAPIError(`collection ${coll.namespace} not found`));
  23. }
  24. callback(err, collections[0].options);
  25. });
  26. }
  27. }
  28. exports.OptionsOperation = OptionsOperation;
  29. //# sourceMappingURL=options_operation.js.map