collections.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CollectionsOperation = void 0;
  4. const collection_1 = require("../collection");
  5. const operation_1 = require("./operation");
  6. /** @internal */
  7. class CollectionsOperation extends operation_1.AbstractOperation {
  8. constructor(db, options) {
  9. super(options);
  10. this.options = options;
  11. this.db = db;
  12. }
  13. async execute(server, session) {
  14. // Let's get the collection names
  15. const documents = await this.db
  16. .listCollections({}, { ...this.options, nameOnly: true, readPreference: this.readPreference, session })
  17. .toArray();
  18. const collections = [];
  19. for (const { name } of documents) {
  20. if (!name.includes('$')) {
  21. // Filter collections removing any illegal ones
  22. collections.push(new collection_1.Collection(this.db, name, this.db.s.options));
  23. }
  24. }
  25. // Return the collection objects
  26. return collections;
  27. }
  28. }
  29. exports.CollectionsOperation = CollectionsOperation;
  30. //# sourceMappingURL=collections.js.map