list_databases.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ListDatabasesOperation = void 0;
  4. const utils_1 = require("../utils");
  5. const command_1 = require("./command");
  6. const operation_1 = require("./operation");
  7. /** @internal */
  8. class ListDatabasesOperation extends command_1.CommandOperation {
  9. constructor(db, options) {
  10. super(db, options);
  11. this.options = options !== null && options !== void 0 ? options : {};
  12. this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
  13. }
  14. execute(server, session, callback) {
  15. const cmd = { listDatabases: 1 };
  16. if (this.options.nameOnly) {
  17. cmd.nameOnly = Number(cmd.nameOnly);
  18. }
  19. if (this.options.filter) {
  20. cmd.filter = this.options.filter;
  21. }
  22. if (typeof this.options.authorizedDatabases === 'boolean') {
  23. cmd.authorizedDatabases = this.options.authorizedDatabases;
  24. }
  25. super.executeCommand(server, session, cmd, callback);
  26. }
  27. }
  28. exports.ListDatabasesOperation = ListDatabasesOperation;
  29. (0, operation_1.defineAspects)(ListDatabasesOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
  30. //# sourceMappingURL=list_databases.js.map