list_databases.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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. // we check for undefined specifically here to allow falsy values
  26. // eslint-disable-next-line no-restricted-syntax
  27. if ((0, utils_1.maxWireVersion)(server) >= 9 && this.options.comment !== undefined) {
  28. cmd.comment = this.options.comment;
  29. }
  30. super.executeCommand(server, session, cmd, callback);
  31. }
  32. }
  33. exports.ListDatabasesOperation = ListDatabasesOperation;
  34. (0, operation_1.defineAspects)(ListDatabasesOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
  35. //# sourceMappingURL=list_databases.js.map