Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const command_1 = require("../command");
  5. const logger_1 = require("../logger");
  6. const requirePermissions_1 = require("../requirePermissions");
  7. const commandUtils_1 = require("../emulator/commandUtils");
  8. const types_1 = require("../emulator/types");
  9. const database_1 = require("../management/database");
  10. const projectUtils_1 = require("../projectUtils");
  11. const getDefaultDatabaseInstance_1 = require("../getDefaultDatabaseInstance");
  12. const error_1 = require("../error");
  13. const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
  14. exports.command = new command_1.Command("database:instances:create <instanceName>")
  15. .description("create a realtime database instance")
  16. .option("-l, --location <location>", "(optional) location for the database instance, defaults to us-central1")
  17. .before(requirePermissions_1.requirePermissions, ["firebasedatabase.instances.create"])
  18. .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.DATABASE)
  19. .action(async (instanceName, options) => {
  20. const projectId = (0, projectUtils_1.needProjectId)(options);
  21. const defaultDatabaseInstance = await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)({ project: projectId });
  22. if (defaultDatabaseInstance === "") {
  23. throw new error_1.FirebaseError(requireDatabaseInstance_1.MISSING_DEFAULT_INSTANCE_ERROR_MESSAGE);
  24. }
  25. const location = (0, database_1.parseDatabaseLocation)(options.location, database_1.DatabaseLocation.US_CENTRAL1);
  26. const instance = await (0, database_1.createInstance)(projectId, instanceName, location, database_1.DatabaseInstanceType.USER_DATABASE);
  27. logger_1.logger.info(`created database instance ${instance.name}`);
  28. return instance;
  29. });